Skip to content

Commit 7fae05a

Browse files
committed
Precompute ecmult at runtime for tests_exhaustive
1 parent 7502d8b commit 7fae05a

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
@@ -66,8 +66,6 @@ static void precompute_ecmult_print_two_tables(FILE *fp, int window_g, const sec
6666

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

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

116-
fprintf(fp, "#endif\n");
110+
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
117111
fprintf(fp, "#undef S\n");
118112
fprintf(fp, "#endif /* SECP256K1_PRECOMPUTED_ECMULT_H */\n");
119113
fclose(fp);

0 commit comments

Comments
 (0)