11#include "../include/secp256k1.h"
28 int spacing =
CEIL_DIV(256, blocks * teeth);
29 size_t points = ((size_t)1) << (teeth - 1);
36 fprintf(fp,
"#elif (COMB_BLOCKS == %d) && (COMB_TEETH == %d) && (COMB_SPACING == %d)\n", blocks, teeth, spacing);
37 for (outer = 0; outer != blocks; outer++) {
39 for (inner = 0; inner != points; inner++) {
40 fprintf(fp,
"S(%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
41 ",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
",%"PRIx32
")",
43 if (inner != points - 1) {
47 if (outer != blocks - 1) {
56int main(
int argc,
char **argv) {
57 const char outfile[] =
"src/precomputed_ecmult_gen.c";
60 int did_current_config = 0;
65 fp =
fopen(outfile,
"w");
67 fprintf(stderr,
"Could not open %s for writing!\n", outfile);
71 fprintf(fp,
"/* This file was automatically generated by precompute_ecmult_gen. */\n");
72 fprintf(fp,
"/* See ecmult_gen_impl.h for details about the contents of this file. */\n");
73 fprintf(fp,
"#include \"group.h\"\n");
74 fprintf(fp,
"#include \"ecmult_gen.h\"\n");
75 fprintf(fp,
"#include \"precomputed_ecmult_gen.h\"\n");
76 fprintf(fp,
"#ifdef EXHAUSTIVE_TEST_ORDER\n");
77 fprintf(fp,
"# error Cannot compile precomputed_ecmult_gen.c in exhaustive test mode\n");
78 fprintf(fp,
"#endif /* EXHAUSTIVE_TEST_ORDER */\n");
79 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");
81 fprintf(fp,
"const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS] = {\n");
82 fprintf(fp,
"#if 0\n");
83 for (config = 0; config <
sizeof(
CONFIGS) /
sizeof(*
CONFIGS); ++config) {
86 did_current_config = 1;
89 if (!did_current_config) {
92 fprintf(fp,
"#else\n");
93 fprintf(fp,
"# error Configuration mismatch, invalid COMB_* parameters. Try deleting precomputed_ecmult_gen.c before the build.\n");
94 fprintf(fp,
"#endif\n");
97 fprintf(fp,
"#undef S\n");
static void secp256k1_ecmult_gen_compute_table(secp256k1_ge_storage *table, const secp256k1_ge *gen, int blocks, int teeth, int spacing)
#define SECP256K1_GE_STORAGE_CONST_GET(t)
static const secp256k1_ge secp256k1_ge_const_g
FILE * fopen(const fs::path &p, const char *mode)
int main(int argc, char **argv)
static const int CONFIGS[][2]
static void print_table(FILE *fp, int blocks, int teeth)
static const secp256k1_callback default_error_callback
static SECP256K1_INLINE void * checked_malloc(const secp256k1_callback *cb, size_t size)