7#ifndef SECP256K1_GROUP_IMPL_H
8#define SECP256K1_GROUP_IMPL_H
17#define SECP256K1_G_ORDER_7 SECP256K1_GE_CONST(\
18 0x66625d13, 0x317ffe44, 0x63d32cff, 0x1ca02b9b,\
19 0xe5c6d070, 0x50b4b05e, 0x81cc30db, 0xf5166f0a,\
20 0x1e60e897, 0xa7c00c7c, 0x2df53eb6, 0x98274ff4,\
21 0x64252f42, 0x8ca44e17, 0x3b25418c, 0xff4ab0cf\
23#define SECP256K1_G_ORDER_13 SECP256K1_GE_CONST(\
24 0xa2482ff8, 0x4bf34edf, 0xa51262fd, 0xe57921db,\
25 0xe0dd2cb7, 0xa5914790, 0xbc71631f, 0xc09704fb,\
26 0x942536cb, 0xa3e49492, 0x3a701cc3, 0xee3e443f,\
27 0xdf182aa9, 0x15b8aa6a, 0x166d3b19, 0xba84b045\
29#define SECP256K1_G_ORDER_199 SECP256K1_GE_CONST(\
30 0x7fb07b5c, 0xd07c3bda, 0x553902e2, 0x7a87ea2c,\
31 0x35108a7f, 0x051f41e5, 0xb76abad5, 0x1f2703ad,\
32 0x0a251539, 0x5b4c4438, 0x952a634f, 0xac10dd4d,\
33 0x6d6f4745, 0x98990c27, 0x3a4f3116, 0xd32ff969\
38#define SECP256K1_G SECP256K1_GE_CONST(\
39 0x79be667e, 0xf9dcbbac, 0x55a06295, 0xce870b07,\
40 0x029bfcdb, 0x2dce28d9, 0x59f2815b, 0x16f81798,\
41 0x483ada77, 0x26a3c465, 0x5da4fbfc, 0x0e1108a8,\
42 0xfd17b448, 0xa6855419, 0x9c47d08f, 0xfb10d4b8\
51#if defined(EXHAUSTIVE_TEST_ORDER)
52# if EXHAUSTIVE_TEST_ORDER == 7
57# elif EXHAUSTIVE_TEST_ORDER == 13
62# elif EXHAUSTIVE_TEST_ORDER == 199
68# error No known generator for the specified exhaustive test group order.
213 for (i = 1; i < len; i++) {
218 for (i = len - 1; i > 0; i--) {
224 for (i = 0; i < len; i++) {
231 for (i = 0; i < len; i++) {
238 for (i = 0; i < len; i++) {
247 size_t last_i = SIZE_MAX;
249 for (i = 0; i < len; i++) {
254 if (last_i == SIZE_MAX) {
262 if (last_i == SIZE_MAX) {
270 if (!a[i].infinity) {
279 for (i = 0; i < len; i++) {
280 if (!a[i].infinity) {
288 for (i = 0; i < len; i++) {
294 for (i = 0; i < len; i++) {
323 for (i = 0; i < len; i++) {
330 for (i = 0; i < len; i++) {
565 secp256k1_fe z22, z12, u1, u2, s1, s2, h, i, h2, h3,
t;
693 secp256k1_fe az, z12, u1, u2, s1, s2, h, i, h2, h3,
t;
763 secp256k1_fe zz, u1, u2, s1, s2,
t, tt,
m, n, q, rr;
970#ifdef EXHAUSTIVE_TEST_ORDER
976 for (i = 0; i < 32; ++i) {
1040 memcpy(buf, &
s, 64);
1051 memcpy(&
s, buf, 64);
1061 memset(
data, 0, 64);
1072 static const unsigned char zeros[64] = { 0 };
1142 memset(out33, 0, 33);
1155 unsigned char zeros[33] = { 0 };
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
#define secp256k1_fe_cmov
#define secp256k1_fe_negate(r, a, m)
Negate a field element.
#define secp256k1_fe_mul_int(r, a)
Multiply a field element with a small integer.
#define secp256k1_fe_normalizes_to_zero_var
#define secp256k1_fe_normalize_weak
static const secp256k1_fe secp256k1_const_beta
#define secp256k1_fe_is_odd
#define SECP256K1_FE_VERIFY_MAGNITUDE(a, m)
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_to_storage
#define secp256k1_fe_inv_var
#define secp256k1_fe_set_b32_limit
#define SECP256K1_FE_VERIFY(a)
#define secp256k1_fe_is_square_var
#define secp256k1_fe_from_storage
#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 1, set *r equal to *a; if flag is 0, leave it.
#define secp256k1_fe_add_int
#define secp256k1_fe_set_int(r, a)
Set a field element to an integer in range [0,0x7FFF].
#define SECP256K1_GE_X_MAGNITUDE_MAX
Maximum allowed magnitudes for group element coordinates in affine (x, y) and jacobian (x,...
#define SECP256K1_GEJ_VERIFY(a)
#define SECP256K1_GEJ_Y_MAGNITUDE_MAX
#define SECP256K1_GE_Y_MAGNITUDE_MAX
#define SECP256K1_GEJ_Z_MAGNITUDE_MAX
#define SECP256K1_GE_VERIFY(a)
#define SECP256K1_GEJ_X_MAGNITUDE_MAX
static SECP256K1_INLINE void secp256k1_ge_impl_serialize33(secp256k1_ge *elem, unsigned char *pub33)
static int secp256k1_gej_eq_var(const secp256k1_gej *a, const secp256k1_gej *b)
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
static SECP256K1_INLINE int secp256k1_ge_impl_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd)
static SECP256K1_INLINE void secp256k1_ge_impl_set_gej_zinv(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zi)
static SECP256K1_INLINE void secp256k1_ge_impl_set_gej(secp256k1_ge *r, secp256k1_gej *a)
static SECP256K1_INLINE void secp256k1_gej_impl_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
static SECP256K1_INLINE void secp256k1_ge_impl_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y)
static SECP256K1_INLINE void secp256k1_gej_impl_neg(secp256k1_gej *r, const secp256k1_gej *a)
static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv)
static SECP256K1_INLINE void secp256k1_gej_impl_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv)
#define SECP256K1_G_ORDER_13
static void secp256k1_gej_clear(secp256k1_gej *r)
static SECP256K1_INLINE int secp256k1_ge_impl_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size)
static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a)
static void secp256k1_gej_set_infinity(secp256k1_gej *r)
static void secp256k1_ge_serialize65(secp256k1_ge *elem, unsigned char *pub65)
static int secp256k1_gej_is_infinity(const secp256k1_gej *a)
static void secp256k1_ge_clear(secp256k1_ge *r)
static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y)
static SECP256K1_INLINE void secp256k1_gej_impl_rescale(secp256k1_gej *r, const secp256k1_fe *s)
static void secp256k1_gej_verify(const secp256k1_gej *a)
static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd)
static SECP256K1_INLINE void secp256k1_gej_impl_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
static void secp256k1_ge_verify(const secp256k1_ge *a)
static SECP256K1_INLINE void secp256k1_ge_impl_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a)
static int secp256k1_ge_eq_var(const secp256k1_ge *a, const secp256k1_ge *b)
static int secp256k1_ge_x_on_curve_var(const secp256k1_fe *x)
static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
static void secp256k1_ge_to_bytes_ext(unsigned char *data, const secp256k1_ge *ge)
static SECP256K1_INLINE void secp256k1_ge_impl_neg(secp256k1_ge *r, const secp256k1_ge *a)
static SECP256K1_INLINE void secp256k1_gej_cmov(secp256k1_gej *r, const secp256k1_gej *a, int flag)
static SECP256K1_INLINE int secp256k1_gej_impl_eq_var(const secp256k1_gej *a, const secp256k1_gej *b)
static SECP256K1_INLINE int secp256k1_ge_impl_eq_var(const secp256k1_ge *a, const secp256k1_ge *b)
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
#define SECP256K1_G
Generator for secp256k1, value 'g' defined in "Standards for Efficient Cryptography" (SEC2) 2....
static SECP256K1_INLINE void secp256k1_ge_impl_to_bytes(unsigned char *buf, const secp256k1_ge *a)
static void secp256k1_ge_set_gej_zinv(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zi)
static SECP256K1_INLINE void secp256k1_ge_impl_from_bytes(secp256k1_ge *r, const unsigned char *buf)
static SECP256K1_INLINE void secp256k1_gej_impl_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
static int secp256k1_gej_eq_ge_var(const secp256k1_gej *a, const secp256k1_ge *b)
static SECP256K1_INLINE int secp256k1_ge_impl_x_frac_on_curve_var(const secp256k1_fe *xn, const secp256k1_fe *xd)
static SECP256K1_INLINE void secp256k1_ge_impl_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
static SECP256K1_INLINE void secp256k1_ge_impl_to_bytes_ext(unsigned char *data, const secp256k1_ge *ge)
static int secp256k1_ge_parse_ext33(secp256k1_ge *ge, const unsigned char *in33)
static SECP256K1_INLINE int secp256k1_gej_impl_eq_ge_var(const secp256k1_gej *a, const secp256k1_ge *b)
static int secp256k1_ge_is_valid_var(const secp256k1_ge *a)
static void secp256k1_ge_serialize33(secp256k1_ge *elem, unsigned char *pub33)
static void secp256k1_ge_from_bytes_ext(secp256k1_ge *ge, const unsigned char *data)
static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a)
static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr)
static SECP256K1_INLINE void secp256k1_ge_impl_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a)
static SECP256K1_INLINE int secp256k1_ge_impl_parse_ext33(secp256k1_ge *ge, const unsigned char *in33)
static SECP256K1_INLINE int secp256k1_gej_impl_is_infinity(const secp256k1_gej *a)
static SECP256K1_INLINE int secp256k1_ge_impl_is_in_correct_subgroup(const secp256k1_ge *ge)
static int secp256k1_ge_x_frac_on_curve_var(const secp256k1_fe *xn, const secp256k1_fe *xd)
static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *s)
static void secp256k1_ge_set_ge_zinv(secp256k1_ge *r, const secp256k1_ge *a, const secp256k1_fe *zi)
static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a)
#define SECP256K1_G_ORDER_7
static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a)
static void secp256k1_ge_serialize_ext33(unsigned char *out33, secp256k1_ge *ge)
static int secp256k1_ge_is_in_correct_subgroup(const secp256k1_ge *ge)
static void secp256k1_ge_table_set_globalz(size_t len, secp256k1_ge *a, const secp256k1_fe *zr)
static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a)
static SECP256K1_INLINE void secp256k1_gej_impl_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr)
static const secp256k1_ge secp256k1_ge_const_g
static SECP256K1_INLINE void secp256k1_ge_impl_set_all_gej(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
static void secp256k1_ge_set_all_gej(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
static int secp256k1_ge_is_infinity(const secp256k1_ge *a)
static void secp256k1_ge_set_infinity(secp256k1_ge *r)
static SECP256K1_INLINE void secp256k1_ge_impl_set_ge_zinv(secp256k1_ge *r, const secp256k1_ge *a, const secp256k1_fe *zi)
static int secp256k1_ge_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size)
static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
static SECP256K1_INLINE void secp256k1_ge_impl_serialize65(secp256k1_ge *elem, unsigned char *pub65)
static SECP256K1_INLINE void secp256k1_gej_impl_cmov(secp256k1_gej *r, const secp256k1_gej *a, int flag)
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a)
static SECP256K1_INLINE int secp256k1_gej_impl_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a)
static SECP256K1_INLINE void secp256k1_ge_impl_serialize_ext33(unsigned char *out33, secp256k1_ge *ge)
static SECP256K1_INLINE int secp256k1_ge_impl_is_infinity(const secp256k1_ge *a)
static void secp256k1_ge_to_bytes(unsigned char *buf, const secp256k1_ge *a)
static SECP256K1_INLINE void secp256k1_gej_impl_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
static SECP256K1_INLINE void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag)
#define SECP256K1_G_ORDER_199
static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a)
static SECP256K1_INLINE void secp256k1_ge_impl_from_bytes_ext(secp256k1_ge *ge, const unsigned char *data)
static SECP256K1_INLINE int secp256k1_ge_impl_x_on_curve_var(const secp256k1_fe *x)
static SECP256K1_INLINE void secp256k1_ge_impl_set_gej_var(secp256k1_ge *r, secp256k1_gej *a)
static SECP256K1_INLINE void secp256k1_ge_impl_table_set_globalz(size_t len, secp256k1_ge *a, const secp256k1_fe *zr)
static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a)
static SECP256K1_INLINE int secp256k1_ge_impl_is_valid_var(const secp256k1_ge *a)
static SECP256K1_INLINE void secp256k1_gej_impl_double(secp256k1_gej *r, const secp256k1_gej *a)
static void secp256k1_ge_from_bytes(secp256k1_ge *r, const unsigned char *buf)
static SECP256K1_INLINE void secp256k1_gej_double(secp256k1_gej *r, const secp256k1_gej *a)
static SECP256K1_INLINE void secp256k1_memclear_explicit(void *ptr, size_t len)
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
#define STATIC_ASSERT(expr)
Assert statically that expr is true.
#define VERIFY_CHECK(cond)
#define SECP256K1_TAG_PUBKEY_EVEN
Prefix byte used to tag various encoded curvepoints for specific purposes.
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN
#define SECP256K1_TAG_PUBKEY_UNCOMPRESSED
#define SECP256K1_TAG_PUBKEY_ODD
This field implementation represents the value as 10 uint32_t limbs in base 2^26.
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
A group element of the secp256k1 curve, in jacobian coordinates.
#define EXHAUSTIVE_TEST_ORDER