Skip to content

Commit

Permalink
refactor: Rename file that contains static ecmult_gen table
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Dec 3, 2021
1 parent 00d2fa1 commit 8ae18f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ $(gen_context_OBJECTS): src/gen_context.c src/libsecp256k1-config.h
$(gen_context_BIN): $(gen_context_OBJECTS)
$(CC_FOR_BUILD) $(SECP_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $^ -o $@

$(libsecp256k1_la_OBJECTS): src/ecmult_static_context.h
$(tests_OBJECTS): src/ecmult_static_context.h
$(exhaustive_tests_OBJECTS): src/ecmult_static_context.h
$(bench_internal_OBJECTS): src/ecmult_static_context.h
$(bench_ecmult_OBJECTS): src/ecmult_static_context.h
$(libsecp256k1_la_OBJECTS): src/ecmult_gen_static_prec_table.h
$(tests_OBJECTS): src/ecmult_gen_static_prec_table.h
$(exhaustive_tests_OBJECTS): src/ecmult_gen_static_prec_table.h
$(bench_internal_OBJECTS): src/ecmult_gen_static_prec_table.h
$(bench_ecmult_OBJECTS): src/ecmult_gen_static_prec_table.h

src/ecmult_static_context.h: $(gen_context_BIN)
src/ecmult_gen_static_prec_table.h: $(gen_context_BIN)
./$(gen_context_BIN)

CLEANFILES = $(gen_context_BIN) src/ecmult_static_context.h
CLEANFILES = $(gen_context_BIN) src/ecmult_gen_static_prec_table.h
endif

EXTRA_DIST = autogen.sh src/gen_context.c src/ecmult_static_pre_g.h src/basic-config.h
Expand Down
2 changes: 1 addition & 1 deletion src/ecmult_gen_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "group.h"
#include "ecmult_gen.h"
#include "hash_impl.h"
#include "ecmult_static_context.h"
#include "ecmult_gen_static_prec_table.h"

static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx) {
secp256k1_ecmult_gen_blind(ctx, NULL);
Expand Down
11 changes: 6 additions & 5 deletions src/gen_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ int main(int argc, char **argv) {
secp256k1_ge_storage* table;
int inner;
int outer;
const char outfile[] = "src/ecmult_gen_static_prec_table.h";
FILE* fp;

(void)argc;
(void)argv;

fp = fopen("src/ecmult_static_context.h","w");
fp = fopen(outfile, "w");
if (fp == NULL) {
fprintf(stderr, "Could not open src/ecmult_static_context.h for writing!\n");
fprintf(stderr, "Could not open %s for writing!\n", outfile);
return -1;
}

fprintf(fp, "#ifndef SECP256K1_ECMULT_STATIC_CONTEXT_H\n");
fprintf(fp, "#define SECP256K1_ECMULT_STATIC_CONTEXT_H\n");
fprintf(fp, "#ifndef SECP256K1_ECMULT_GEN_STATIC_PREC_TABLE_H\n");
fprintf(fp, "#define SECP256K1_ECMULT_GEN_STATIC_PREC_TABLE_H\n");
fprintf(fp, "#include \"src/group.h\"\n");
fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n");
fprintf(fp, "#if ECMULT_GEN_PREC_N != %d || ECMULT_GEN_PREC_G != %d\n", ECMULT_GEN_PREC_N, ECMULT_GEN_PREC_G);
fprintf(fp, " #error configuration mismatch, invalid ECMULT_GEN_PREC_N, ECMULT_GEN_PREC_G. Try deleting ecmult_static_context.h before the build.\n");
fprintf(fp, " #error configuration mismatch, invalid ECMULT_GEN_PREC_N, ECMULT_GEN_PREC_G. Try deleting %s before the build.\n", outfile);
fprintf(fp, "#endif\n");
fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N][ECMULT_GEN_PREC_G] = {\n");

Expand Down

0 comments on commit 8ae18f1

Please sign in to comment.