10#include "../include/secp256k1.h"
25 fprintf(fp,
"const secp256k1_ge_storage %s[ECMULT_TABLE_SIZE(WINDOW_G)] = {\n",
name);
26 fprintf(fp,
" S(%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
27 ",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
")\n",
31 for(i = 3; i <= window_g; ++i) {
32 fprintf(fp,
"#if WINDOW_G > %d\n", i-1);
34 fprintf(fp,
",S(%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
35 ",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
")\n",
38 fprintf(fp,
"#endif\n");
49 print_table(fp,
"secp256k1_pre_g", window_g, table);
50 print_table(fp,
"secp256k1_pre_g_128", window_g, table_128);
59 const char outfile[] =
"src/precomputed_ecmult.c";
62 fp =
fopen(outfile,
"w");
64 fprintf(stderr,
"Could not open %s for writing!\n", outfile);
68 fprintf(fp,
"/* This file was automatically generated by precompute_ecmult. */\n");
69 fprintf(fp,
"/* This file contains an array secp256k1_pre_g with odd multiples of the base point G and\n");
70 fprintf(fp,
" * an array secp256k1_pre_g_128 with odd multiples of 2^128*G for accelerating the computation of a*P + b*G.\n");
72 fprintf(fp,
"#include \"group.h\"\n");
73 fprintf(fp,
"#include \"ecmult.h\"\n");
74 fprintf(fp,
"#include \"precomputed_ecmult.h\"\n");
75 fprintf(fp,
"#define S(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SECP256K1_GE_STORAGE_CONST(0x##a##u,0x##b##u,0x##c##u,0x##d##u,0x##e##u,0x##f##u,0x##g##u,0x##h##u,0x##i##u,0x##j##u,0x##k##u,0x##l##u,0x##m##u,0x##n##u,0x##o##u,0x##p##u)\n");
76 fprintf(fp,
"#if ECMULT_WINDOW_SIZE > %d\n", window_g);
77 fprintf(fp,
" #error configuration mismatch, invalid ECMULT_WINDOW_SIZE. Try deleting precomputed_ecmult.c before the build.\n");
78 fprintf(fp,
"#endif\n");
79 fprintf(fp,
"#ifdef EXHAUSTIVE_TEST_ORDER\n");
80 fprintf(fp,
"# error Cannot compile precomputed_ecmult.c in exhaustive test mode\n");
81 fprintf(fp,
"#endif /* EXHAUSTIVE_TEST_ORDER */\n");
82 fprintf(fp,
"#define WINDOW_G ECMULT_WINDOW_SIZE\n");
86 fprintf(fp,
"#undef S\n");
#define ECMULT_TABLE_SIZE(w)
The number of entries a table with precomputed multiples needs to have.
#define ECMULT_WINDOW_SIZE
static void secp256k1_ecmult_compute_two_tables(secp256k1_ge_storage *table, secp256k1_ge_storage *table_128, int window_g, const secp256k1_ge *gen)
#define SECP256K1_GE_STORAGE_CONST_GET(t)
static const secp256k1_ge secp256k1_ge_const_g
FILE * fopen(const fs::path &p, const char *mode)
static void print_two_tables(FILE *fp, int window_g)
static void print_table(FILE *fp, const char *name, int window_g, const secp256k1_ge_storage *table)