7#ifndef SECP256K1_FIELD_H
8#define SECP256K1_FIELD_H
33# define SECP256K1_FE_VERIFY_FIELDS \
37# define SECP256K1_FE_VERIFY_FIELDS
40#if defined(SECP256K1_WIDEMUL_INT128)
42#elif defined(SECP256K1_WIDEMUL_INT64)
45#error "Please select wide multiplication implementation"
50#define SECP256K1_FE_VERIFY_CONST(d7, d6, d5, d4, d3, d2, d1, d0) \
52 , (((d7) | (d6) | (d5) | (d4) | (d3) | (d2) | (d1) | (d0)) != 0) \
54 , (!(((d7) & (d6) & (d5) & (d4) & (d3) & (d2)) == 0xfffffffful && ((d1) == 0xfffffffful || ((d1) == 0xfffffffe && (d0 >= 0xfffffc2f)))))
56#define SECP256K1_FE_VERIFY_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
66#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)) SECP256K1_FE_VERIFY_CONST((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)) }
70 0x7ae96a2bul, 0x657c0710ul, 0x6e64479eul, 0xac3434e9ul,
71 0x9cf04975ul, 0x12f58995ul, 0xc1396c28ul, 0x719501eeul
78# define secp256k1_fe_normalize secp256k1_fe_impl_normalize
79# define secp256k1_fe_normalize_weak secp256k1_fe_impl_normalize_weak
80# define secp256k1_fe_normalize_var secp256k1_fe_impl_normalize_var
81# define secp256k1_fe_normalizes_to_zero secp256k1_fe_impl_normalizes_to_zero
82# define secp256k1_fe_normalizes_to_zero_var secp256k1_fe_impl_normalizes_to_zero_var
83# define secp256k1_fe_set_int secp256k1_fe_impl_set_int
84# define secp256k1_fe_is_zero secp256k1_fe_impl_is_zero
85# define secp256k1_fe_is_odd secp256k1_fe_impl_is_odd
86# define secp256k1_fe_cmp_var secp256k1_fe_impl_cmp_var
87# define secp256k1_fe_set_b32_mod secp256k1_fe_impl_set_b32_mod
88# define secp256k1_fe_set_b32_limit secp256k1_fe_impl_set_b32_limit
89# define secp256k1_fe_get_b32 secp256k1_fe_impl_get_b32
90# define secp256k1_fe_negate_unchecked secp256k1_fe_impl_negate_unchecked
91# define secp256k1_fe_mul_int_unchecked secp256k1_fe_impl_mul_int_unchecked
92# define secp256k1_fe_add secp256k1_fe_impl_add
93# define secp256k1_fe_mul secp256k1_fe_impl_mul
94# define secp256k1_fe_sqr secp256k1_fe_impl_sqr
95# define secp256k1_fe_cmov secp256k1_fe_impl_cmov
96# define secp256k1_fe_to_storage secp256k1_fe_impl_to_storage
97# define secp256k1_fe_from_storage secp256k1_fe_impl_from_storage
98# define secp256k1_fe_inv secp256k1_fe_impl_inv
99# define secp256k1_fe_inv_var secp256k1_fe_impl_inv_var
100# define secp256k1_fe_get_bounds secp256k1_fe_impl_get_bounds
101# define secp256k1_fe_half secp256k1_fe_impl_half
102# define secp256k1_fe_add_int secp256k1_fe_impl_add_int
103# define secp256k1_fe_is_square_var secp256k1_fe_impl_is_square_var
211#define secp256k1_fe_negate(r, a, m) ASSERT_INT_CONST_AND_DO(m, secp256k1_fe_negate_unchecked(r, a, m))
233#define secp256k1_fe_mul_int(r, a) ASSERT_INT_CONST_AND_DO(a, secp256k1_fe_mul_int_unchecked(r, a))
344#define SECP256K1_FE_VERIFY(a) secp256k1_fe_verify(a)
348#define SECP256K1_FE_VERIFY_MAGNITUDE(a, m) secp256k1_fe_verify_magnitude(a, m)
#define secp256k1_fe_cmov
#define secp256k1_fe_normalizes_to_zero_var
static void secp256k1_fe_clear(secp256k1_fe *a)
Clear a field element to prevent leaking sensitive information.
#define secp256k1_fe_cmp_var
static void secp256k1_fe_verify_magnitude(const secp256k1_fe *a, int m)
Check that magnitude of a is at most m (no-op unless VERIFY is enabled).
#define secp256k1_fe_normalize_weak
static const secp256k1_fe secp256k1_const_beta
static void secp256k1_fe_verify(const secp256k1_fe *a)
Check invariants on a field element (no-op unless VERIFY is enabled).
#define secp256k1_fe_is_odd
static const secp256k1_fe secp256k1_fe_one
static int secp256k1_fe_sqrt(secp256k1_fe *SECP256K1_RESTRICT r, const secp256k1_fe *SECP256K1_RESTRICT a)
Compute a square root of a field element.
#define secp256k1_fe_normalize_var
#define secp256k1_fe_half
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
This expands to an initializer for a secp256k1_fe valued sum((i*32) * d_i, i=0..7) mod p.
#define secp256k1_fe_to_storage
#define secp256k1_fe_inv_var
#define secp256k1_fe_is_zero
#define secp256k1_fe_mul_int_unchecked
#define secp256k1_fe_set_b32_limit
#define secp256k1_fe_is_square_var
#define secp256k1_fe_get_bounds
#define secp256k1_fe_from_storage
#define secp256k1_fe_set_b32_mod
#define secp256k1_fe_negate_unchecked
#define secp256k1_fe_get_b32
#define secp256k1_fe_normalizes_to_zero
#define secp256k1_fe_normalize
static int secp256k1_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b)
Determine whether two field elements are equal.
static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
#define secp256k1_fe_add_int
#define secp256k1_fe_set_int
#define SECP256K1_RESTRICT
This field implementation represents the value as 10 uint32_t limbs in base 2^26.