Skip to content

Commit dddb682

Browse files
committed
Precompute ecmult at runtime for tests_exhaustive
1 parent f7d2daa commit dddb682

File tree

3 files changed

+9
-155
lines changed

3 files changed

+9
-155
lines changed

src/precompute.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ static void precompute_ecmult_print_two_tables(FILE *fp, int window_g, const sec
6565

6666
static int precompute_ecmult(void) {
6767
const secp256k1_ge g = SECP256K1_G;
68-
const secp256k1_ge g_13 = SECP256K1_G_ORDER_13;
69-
const secp256k1_ge g_199 = SECP256K1_G_ORDER_199;
7068
const int window_g_13 = 4;
7169
const int window_g_199 = 8;
7270
FILE* fp;
@@ -96,23 +94,19 @@ static int precompute_ecmult(void) {
9694
fprintf(fp, "#if defined(EXHAUSTIVE_TEST_ORDER)\n");
9795
fprintf(fp, "#if EXHAUSTIVE_TEST_ORDER == 13\n");
9896
fprintf(fp, "#define WINDOW_G %d\n", window_g_13);
99-
100-
precompute_ecmult_print_two_tables(fp, window_g_13, &g_13, 0);
101-
10297
fprintf(fp, "#elif EXHAUSTIVE_TEST_ORDER == 199\n");
10398
fprintf(fp, "#define WINDOW_G %d\n", window_g_199);
104-
105-
precompute_ecmult_print_two_tables(fp, window_g_199, &g_199, 0);
106-
10799
fprintf(fp, "#else\n");
108100
fprintf(fp, " #error No known generator for the specified exhaustive test group order.\n");
109101
fprintf(fp, "#endif\n");
102+
fprintf(fp, "static secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];\n");
103+
fprintf(fp, "static secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];\n");
110104
fprintf(fp, "#else /* !defined(EXHAUSTIVE_TEST_ORDER) */\n");
111105
fprintf(fp, "#define WINDOW_G ECMULT_WINDOW_SIZE\n");
112106

113107
precompute_ecmult_print_two_tables(fp, ECMULT_WINDOW_SIZE, &g, 1);
114108

115-
fprintf(fp, "#endif\n");
109+
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
116110
fprintf(fp, "#undef S\n");
117111
fprintf(fp, "#endif /* SECP256K1_PRECOMPUTED_ECMULT_H */\n");
118112
fclose(fp);

0 commit comments

Comments
 (0)