@@ -21,7 +21,6 @@ typedef struct {
2121
2222#define SECP256K1_GE_CONST (a , b , c , d , e , f , g , h , i , j , k , l , m , n , o , p ) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), 0}
2323#define SECP256K1_GE_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1}
24- static const secp256k1_ge secp256k1_ge_const_g ;
2524
2625/** A group element of the secp256k1 curve, in jacobian coordinates.
2726 * Note: For exhastive test mode, secp256k1 is replaced by a small subgroup of a different curve.
@@ -53,6 +52,68 @@ typedef struct {
5352#define SECP256K1_GEJ_Y_MAGNITUDE_MAX 4
5453#define SECP256K1_GEJ_Z_MAGNITUDE_MAX 1
5554
55+ /* Begin of section generated by sage/gen_exhaustive_groups.sage. */
56+ #define SECP256K1_G_ORDER_7 SECP256K1_GE_CONST(\
57+ 0x66625d13, 0x317ffe44, 0x63d32cff, 0x1ca02b9b,\
58+ 0xe5c6d070, 0x50b4b05e, 0x81cc30db, 0xf5166f0a,\
59+ 0x1e60e897, 0xa7c00c7c, 0x2df53eb6, 0x98274ff4,\
60+ 0x64252f42, 0x8ca44e17, 0x3b25418c, 0xff4ab0cf\
61+ )
62+ #define SECP256K1_G_ORDER_13 SECP256K1_GE_CONST(\
63+ 0xa2482ff8, 0x4bf34edf, 0xa51262fd, 0xe57921db,\
64+ 0xe0dd2cb7, 0xa5914790, 0xbc71631f, 0xc09704fb,\
65+ 0x942536cb, 0xa3e49492, 0x3a701cc3, 0xee3e443f,\
66+ 0xdf182aa9, 0x15b8aa6a, 0x166d3b19, 0xba84b045\
67+ )
68+ #define SECP256K1_G_ORDER_199 SECP256K1_GE_CONST(\
69+ 0x7fb07b5c, 0xd07c3bda, 0x553902e2, 0x7a87ea2c,\
70+ 0x35108a7f, 0x051f41e5, 0xb76abad5, 0x1f2703ad,\
71+ 0x0a251539, 0x5b4c4438, 0x952a634f, 0xac10dd4d,\
72+ 0x6d6f4745, 0x98990c27, 0x3a4f3116, 0xd32ff969\
73+ )
74+ /** Generator for secp256k1, value 'g' defined in
75+ * "Standards for Efficient Cryptography" (SEC2) 2.7.1.
76+ */
77+ #define SECP256K1_G SECP256K1_GE_CONST(\
78+ 0x79be667e, 0xf9dcbbac, 0x55a06295, 0xce870b07,\
79+ 0x029bfcdb, 0x2dce28d9, 0x59f2815b, 0x16f81798,\
80+ 0x483ada77, 0x26a3c465, 0x5da4fbfc, 0x0e1108a8,\
81+ 0xfd17b448, 0xa6855419, 0x9c47d08f, 0xfb10d4b8\
82+ )
83+ /* These exhaustive group test orders and generators are chosen such that:
84+ * - The field size is equal to that of secp256k1, so field code is the same.
85+ * - The curve equation is of the form y^2=x^3+B for some small constant B.
86+ * - The subgroup has a generator 2*P, where P.x is as small as possible.
87+ * - The subgroup has size less than 1000 to permit exhaustive testing.
88+ * - The subgroup admits an endomorphism of the form lambda*(x,y) == (beta*x,y).
89+ */
90+ #if defined(EXHAUSTIVE_TEST_ORDER )
91+ # if EXHAUSTIVE_TEST_ORDER == 7
92+
93+ static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_G_ORDER_7 ;
94+ #define SECP256K1_B 6
95+
96+ # elif EXHAUSTIVE_TEST_ORDER == 13
97+
98+ static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_G_ORDER_13 ;
99+ #define SECP256K1_B 2
100+
101+ # elif EXHAUSTIVE_TEST_ORDER == 199
102+
103+ static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_G_ORDER_199 ;
104+ #define SECP256K1_B 4
105+
106+ # else
107+ # error No known generator for the specified exhaustive test group order.
108+ # endif
109+ #else
110+
111+ static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_G ;
112+ #define SECP256K1_B 7
113+
114+ #endif
115+ /* End of section generated by sage/gen_exhaustive_groups.sage. */
116+
56117/** Set a group element equal to the point with given X and Y coordinates */
57118static void secp256k1_ge_set_xy (secp256k1_ge * r , const secp256k1_fe * x , const secp256k1_fe * y );
58119
0 commit comments