Skip to content

Commit 5106226

Browse files
exhaustive_tests: Fix with ecmult_gen table with custom generator
1 parent e1a7653 commit 5106226

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/gen_ecmult_gen_static_prec_table.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,18 @@ int main(int argc, char **argv) {
5252

5353
fprintf(fp, "#ifndef SECP256K1_ECMULT_GEN_STATIC_PREC_TABLE_H\n");
5454
fprintf(fp, "#define SECP256K1_ECMULT_GEN_STATIC_PREC_TABLE_H\n");
55+
5556
fprintf(fp, "#include \"src/group.h\"\n");
57+
5658
fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n");
59+
5760
fprintf(fp, "#if ECMULT_GEN_PREC_N != %d || ECMULT_GEN_PREC_G != %d\n", ECMULT_GEN_PREC_N, ECMULT_GEN_PREC_G);
5861
fprintf(fp, " #error configuration mismatch, invalid ECMULT_GEN_PREC_N, ECMULT_GEN_PREC_G. Try deleting %s before the build.\n", outfile);
5962
fprintf(fp, "#endif\n");
63+
64+
fprintf(fp, "#ifdef EXHAUSTIVE_TEST_ORDER\n");
65+
fprintf(fp, "static secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N][ECMULT_GEN_PREC_G];\n");
66+
fprintf(fp, "#else\n");
6067
fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N][ECMULT_GEN_PREC_G] = {\n");
6168

6269
table = checked_malloc(&default_error_callback, ECMULT_GEN_PREC_TABLE_SIZE);
@@ -80,8 +87,9 @@ int main(int argc, char **argv) {
8087
fprintf(fp,"};\n");
8188
free(table);
8289

90+
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
8391
fprintf(fp, "#undef SC\n");
84-
fprintf(fp, "#endif\n");
92+
fprintf(fp, "#endif /* SECP256K1_ECMULT_GEN_STATIC_PREC_TABLE_H */\n");
8593
fclose(fp);
8694

8795
return 0;

src/tests_exhaustive.c

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "assumptions.h"
2323
#include "group.h"
2424
#include "testrand_impl.h"
25+
#include "ecmult_gen_prec_impl.h"
2526

2627
static int count = 2;
2728

@@ -388,6 +389,9 @@ int main(int argc, char** argv) {
388389
printf("running tests for core %lu (out of [0..%lu])\n", (unsigned long)this_core, (unsigned long)num_cores - 1);
389390
}
390391

392+
/* Recreate the ecmult_gen table using the right generator (as selected via EXHAUSTIVE_TEST_ORDER) */
393+
secp256k1_ecmult_gen_create_prec_table(&secp256k1_ecmult_gen_prec_table[0][0], &secp256k1_ge_const_g);
394+
391395
while (count--) {
392396
/* Build context */
393397
ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);

0 commit comments

Comments
 (0)