Skip to content

Commit 38cd84a

Browse files
committed
Compute ecmult tables at runtime for tests_exhaustive
1 parent e458ec2 commit 38cd84a

File tree

3 files changed

+9
-155
lines changed

3 files changed

+9
-155
lines changed

src/precompute_ecmult.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ static void print_two_tables(FILE *fp, int window_g, const secp256k1_ge *g, int
6262

6363
int main(void) {
6464
const secp256k1_ge g = SECP256K1_G;
65-
const secp256k1_ge g_13 = SECP256K1_G_ORDER_13;
66-
const secp256k1_ge g_199 = SECP256K1_G_ORDER_199;
6765
const int window_g_13 = 4;
6866
const int window_g_199 = 8;
6967
FILE* fp;
@@ -93,23 +91,19 @@ int main(void) {
9391
fprintf(fp, "#if defined(EXHAUSTIVE_TEST_ORDER)\n");
9492
fprintf(fp, "#if EXHAUSTIVE_TEST_ORDER == 13\n");
9593
fprintf(fp, "#define WINDOW_G %d\n", window_g_13);
96-
97-
print_two_tables(fp, window_g_13, &g_13, 0);
98-
9994
fprintf(fp, "#elif EXHAUSTIVE_TEST_ORDER == 199\n");
10095
fprintf(fp, "#define WINDOW_G %d\n", window_g_199);
101-
102-
print_two_tables(fp, window_g_199, &g_199, 0);
103-
10496
fprintf(fp, "#else\n");
10597
fprintf(fp, " #error No known generator for the specified exhaustive test group order.\n");
10698
fprintf(fp, "#endif\n");
99+
fprintf(fp, "static secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];\n");
100+
fprintf(fp, "static secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];\n");
107101
fprintf(fp, "#else /* !defined(EXHAUSTIVE_TEST_ORDER) */\n");
108102
fprintf(fp, "#define WINDOW_G ECMULT_WINDOW_SIZE\n");
109103

110104
print_two_tables(fp, ECMULT_WINDOW_SIZE, &g, 1);
111105

112-
fprintf(fp, "#endif\n");
106+
fprintf(fp, "#endif /* defined(EXHAUSTIVE_TEST_ORDER) */\n");
113107
fprintf(fp, "#undef S\n");
114108
fprintf(fp, "#endif /* SECP256K1_PRECOMPUTED_ECMULT_H */\n");
115109
fclose(fp);

0 commit comments

Comments
 (0)