Skip to content

Commit 69b4bc9

Browse files
committed
Simplify precompute_ecmult_print_*
1 parent 73e8814 commit 69b4bc9

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/precompute.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "ecmult_gen_prec_impl.h"
2626
#include "ecmult_prec_impl.h"
2727

28-
static void precompute_ecmult_print_table(FILE *fp, const char *name, int window_g, const secp256k1_ge_storage* table, int with_conditionals) {
28+
static void precompute_ecmult_print_table(FILE *fp, const char *name, int window_g, const secp256k1_ge_storage* table) {
2929
int j;
3030
int i;
3131

@@ -37,29 +37,25 @@ static void precompute_ecmult_print_table(FILE *fp, const char *name, int window
3737

3838
j = 1;
3939
for(i = 3; i <= window_g; ++i) {
40-
if (with_conditionals) {
41-
fprintf(fp, "#if ECMULT_TABLE_SIZE(WINDOW_G) > %ld\n", ECMULT_TABLE_SIZE(i-1));
42-
}
40+
fprintf(fp, "#if ECMULT_TABLE_SIZE(WINDOW_G) > %ld\n", ECMULT_TABLE_SIZE(i-1));
4341
for(;j < ECMULT_TABLE_SIZE(i); ++j) {
4442
fprintf(fp, ",S(%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32
4543
",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32")\n",
4644
SECP256K1_GE_STORAGE_CONST_GET(table[j]));
4745
}
48-
if (with_conditionals) {
49-
fprintf(fp, "#endif\n");
50-
}
46+
fprintf(fp, "#endif\n");
5147
}
5248
fprintf(fp, "};\n");
5349
}
5450

55-
static void precompute_ecmult_print_two_tables(FILE *fp, int window_g, const secp256k1_ge *g, int with_conditionals) {
51+
static void precompute_ecmult_print_two_tables(FILE *fp, int window_g, const secp256k1_ge *g) {
5652
secp256k1_ge_storage* table = malloc(ECMULT_TABLE_SIZE(window_g) * sizeof(secp256k1_ge_storage));
5753
secp256k1_ge_storage* table_128 = malloc(ECMULT_TABLE_SIZE(window_g) * sizeof(secp256k1_ge_storage));
5854

5955
secp256k1_ecmult_create_prec_two_tables(table, table_128, window_g, g);
6056

61-
precompute_ecmult_print_table(fp, "secp256k1_pre_g", window_g, table, with_conditionals);
62-
precompute_ecmult_print_table(fp, "secp256k1_pre_g_128", window_g, table_128, with_conditionals);
57+
precompute_ecmult_print_table(fp, "secp256k1_pre_g", window_g, table);
58+
precompute_ecmult_print_table(fp, "secp256k1_pre_g_128", window_g, table_128);
6359

6460
free(table);
6561
free(table_128);
@@ -106,7 +102,7 @@ static int precompute_ecmult(void) {
106102
fprintf(fp, "#else /* !defined(EXHAUSTIVE_TEST_ORDER) */\n");
107103
fprintf(fp, "#define WINDOW_G ECMULT_WINDOW_SIZE\n");
108104

109-
precompute_ecmult_print_two_tables(fp, ECMULT_WINDOW_SIZE, &g, 1);
105+
precompute_ecmult_print_two_tables(fp, ECMULT_WINDOW_SIZE, &g);
110106

111107
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
112108
fprintf(fp, "#undef S\n");

0 commit comments

Comments
 (0)