6 * Copyright (c) 2015-2016 Cryptography Research, Inc. \n
7 * Released under the MIT License. See LICENSE.txt for license information.
9 * @brief Field-specific code for 2^448 - 2^224 - 1.
11 * @warning This file was automatically generated in Python.
12 * Please do not edit it.
15 #ifndef __P448_F_FIELD_H__
16 #define __P448_F_FIELD_H__ 1
18 #include "constant_time.h"
24 #define __DECAF_448_GF_DEFINED__ 1
25 #define NLIMBS (64/sizeof(word_t))
26 #define X_SER_BYTES 56
28 typedef struct gf_448_s {
30 } __attribute__((aligned(32))) gf_448_s, gf_448_t[1];
32 #define GF_LIT_LIMB_BITS 56
34 #define ZERO gf_448_ZERO
35 #define ONE gf_448_ONE
36 #define MODULUS gf_448_MODULUS
39 #define gf_eq gf_448_eq
40 #define gf_hibit gf_448_hibit
41 #define gf_lobit gf_448_lobit
42 #define gf_copy gf_448_copy
43 #define gf_add gf_448_add
44 #define gf_sub gf_448_sub
45 #define gf_add_RAW gf_448_add_RAW
46 #define gf_sub_RAW gf_448_sub_RAW
47 #define gf_bias gf_448_bias
48 #define gf_weak_reduce gf_448_weak_reduce
49 #define gf_strong_reduce gf_448_strong_reduce
50 #define gf_mul gf_448_mul
51 #define gf_sqr gf_448_sqr
52 #define gf_mulw_unsigned gf_448_mulw_unsigned
53 #define gf_isr gf_448_isr
54 #define gf_serialize gf_448_serialize
55 #define gf_deserialize gf_448_deserialize
57 /* RFC 7748 support */
58 #define X_PUBLIC_BYTES X_SER_BYTES
59 #define X_PRIVATE_BYTES X_PUBLIC_BYTES
60 #define X_PRIVATE_BITS 448
62 #define INLINE_UNUSED __inline__ __attribute__((unused,always_inline))
68 /* Defined below in f_impl.h */
69 static INLINE_UNUSED void gf_copy (gf out, const gf a) { *out = *a; }
70 static INLINE_UNUSED void gf_add_RAW (gf out, const gf a, const gf b);
71 static INLINE_UNUSED void gf_sub_RAW (gf out, const gf a, const gf b);
72 static INLINE_UNUSED void gf_bias (gf inout, int amount);
73 static INLINE_UNUSED void gf_weak_reduce (gf inout);
75 void gf_strong_reduce (gf inout);
76 void gf_add (gf out, const gf a, const gf b);
77 void gf_sub (gf out, const gf a, const gf b);
78 void gf_mul (gf_s *__restrict__ out, const gf a, const gf b);
79 void gf_mulw_unsigned (gf_s *__restrict__ out, const gf a, uint32_t b);
80 void gf_sqr (gf_s *__restrict__ out, const gf a);
81 mask_t gf_isr(gf a, const gf x); /** a^2 x = 1, QNR, or 0 if x=0. Return true if successful */
82 mask_t gf_eq (const gf x, const gf y);
83 mask_t gf_lobit (const gf x);
84 mask_t gf_hibit (const gf x);
86 void gf_serialize (uint8_t *serial, const gf x,int with_highbit);
87 mask_t gf_deserialize (gf x, const uint8_t serial[SER_BYTES],int with_hibit,uint8_t hi_nmask);
94 #include "f_impl.h" /* Bring in the inline implementations */
97 #define LIMBPERM(i) (i)
99 #define LIMB_MASK(i) (((1ull)<<LIMB_PLACE_VALUE(i))-1)
101 static const gf ZERO = {{{0}}}, ONE = {{{ [LIMBPERM(0)] = 1 }}};
103 #endif /* __P448_F_FIELD_H__ */