|
11 | 11 | #include "field.h" |
12 | 12 | #include "group.h" |
13 | 13 |
|
14 | | -/* These points can be generated in sage as follows: |
| 14 | +/* These exhaustive group test orders and generators are chosen such that: |
| 15 | + * - The field size is equal to that of secp256k1, so field code is the same. |
| 16 | + * - The curve equation is of the form y^2=x^3+B for some constant B. |
| 17 | + * - The subgroup has a generator 2*P, where P.x=1. |
| 18 | + * - The subgroup has size less than 1000 to permit exhaustive testing. |
| 19 | + * - The subgroup admits an endomorphism of the form lambda*(x,y) == (beta*x,y). |
15 | 20 | * |
16 | | - * 0. Setup a worksheet with the following parameters. |
17 | | - * b = 4 # whatever secp256k1_fe_const_b will be set to |
18 | | - * F = FiniteField (0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F) |
19 | | - * C = EllipticCurve ([F (0), F (b)]) |
20 | | - * |
21 | | - * 1. Determine all the small orders available to you. (If there are |
22 | | - * no satisfactory ones, go back and change b.) |
23 | | - * print C.order().factor(limit=1000) |
24 | | - * |
25 | | - * 2. Choose an order as one of the prime factors listed in the above step. |
26 | | - * (You can also multiply some to get a composite order, though the |
27 | | - * tests will crash trying to invert scalars during signing.) We take a |
28 | | - * random point and scale it to drop its order to the desired value. |
29 | | - * There is some probability this won't work; just try again. |
30 | | - * order = 199 |
31 | | - * P = C.random_point() |
32 | | - * P = (int(P.order()) / int(order)) * P |
33 | | - * assert(P.order() == order) |
34 | | - * |
35 | | - * 3. Print the values. You'll need to use a vim macro or something to |
36 | | - * split the hex output into 4-byte chunks. |
37 | | - * print "%x %x" % P.xy() |
| 21 | + * These parameters are generated using sage/gen_exhaustive_groups.sage. |
38 | 22 | */ |
39 | 23 | #if defined(EXHAUSTIVE_TEST_ORDER) |
40 | | -# if EXHAUSTIVE_TEST_ORDER == 199 |
| 24 | +# if EXHAUSTIVE_TEST_ORDER == 13 |
41 | 25 | static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( |
42 | | - 0xFA7CC9A7, 0x0737F2DB, 0xA749DD39, 0x2B4FB069, |
43 | | - 0x3B017A7D, 0xA808C2F1, 0xFB12940C, 0x9EA66C18, |
44 | | - 0x78AC123A, 0x5ED8AEF3, 0x8732BC91, 0x1F3A2868, |
45 | | - 0x48DF246C, 0x808DAE72, 0xCFE52572, 0x7F0501ED |
| 26 | + 0xc3459c3d, 0x35326167, 0xcd86cce8, 0x07a2417f, |
| 27 | + 0x5b8bd567, 0xde8538ee, 0x0d507b0c, 0xd128f5bb, |
| 28 | + 0x8e467fec, 0xcd30000a, 0x6cc1184e, 0x25d382c2, |
| 29 | + 0xa2f4494e, 0x2fbe9abc, 0x8b64abac, 0xd005fb24 |
46 | 30 | ); |
47 | | - |
48 | | -static const secp256k1_fe secp256k1_fe_const_b = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 4); |
49 | | - |
50 | | -# elif EXHAUSTIVE_TEST_ORDER == 13 |
| 31 | +static const secp256k1_fe secp256k1_fe_const_b = SECP256K1_FE_CONST( |
| 32 | + 0x3d3486b2, 0x159a9ca5, 0xc75638be, 0xb23a69bc, |
| 33 | + 0x946a45ab, 0x24801247, 0xb4ed2b8e, 0x26b6a417 |
| 34 | +); |
| 35 | +# elif EXHAUSTIVE_TEST_ORDER == 199 |
51 | 36 | static const secp256k1_ge secp256k1_ge_const_g = SECP256K1_GE_CONST( |
52 | | - 0xedc60018, 0xa51a786b, 0x2ea91f4d, 0x4c9416c0, |
53 | | - 0x9de54c3b, 0xa1316554, 0x6cf4345c, 0x7277ef15, |
54 | | - 0x54cb1b6b, 0xdc8c1273, 0x087844ea, 0x43f4603e, |
55 | | - 0x0eaf9a43, 0xf6effe55, 0x939f806d, 0x37adf8ac |
| 37 | + 0x226e653f, 0xc8df7744, 0x9bacbf12, 0x7d1dcbf9, |
| 38 | + 0x87f05b2a, 0xe7edbd28, 0x1f564575, 0xc48dcf18, |
| 39 | + 0xa13872c2, 0xe933bb17, 0x5d9ffd5b, 0xb5b6e10c, |
| 40 | + 0x57fe3c00, 0xbaaaa15a, 0xe003ec3e, 0x9c269bae |
| 41 | +); |
| 42 | +static const secp256k1_fe secp256k1_fe_const_b = SECP256K1_FE_CONST( |
| 43 | + 0x2cca28fa, 0xfc614b80, 0x2a3db42b, 0x00ba00b1, |
| 44 | + 0xbea8d943, 0xdace9ab2, 0x9536daea, 0x0074defb |
56 | 45 | ); |
57 | | - |
58 | | -static const secp256k1_fe secp256k1_fe_const_b = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 2); |
59 | | - |
60 | 46 | # else |
61 | 47 | # error No known generator for the specified exhaustive test group order. |
62 | 48 | # endif |
|
0 commit comments