59 {
60
62 FILE* fp;
63
64 fp = fopen("src/precomputed_ecmult.c","w");
65 if (fp == NULL) {
66 fprintf(stderr, "Could not open src/precomputed_ecmult.h for writing!\n");
67 return -1;
68 }
69
70 fprintf(fp, "/* This file was automatically generated by precompute_ecmult. */\n");
71 fprintf(fp, "/* This file contains an array secp256k1_pre_g with odd multiples of the base point G and\n");
72 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");
73 fprintf(fp, " */\n");
74 fprintf(fp, "#if defined HAVE_CONFIG_H\n");
75 fprintf(fp, "# include \"libsecp256k1-config.h\"\n");
76 fprintf(fp, "#endif\n");
77 fprintf(fp, "#include \"../include/secp256k1.h\"\n");
78 fprintf(fp, "#include \"group.h\"\n");
79 fprintf(fp, "#include \"ecmult.h\"\n");
80 fprintf(fp, "#include \"precomputed_ecmult.h\"\n");
81 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");
82 fprintf(fp, "#if ECMULT_WINDOW_SIZE > %d\n", window_g);
83 fprintf(fp, " #error configuration mismatch, invalid ECMULT_WINDOW_SIZE. Try deleting precomputed_ecmult.c before the build.\n");
84 fprintf(fp, "#endif\n");
85 fprintf(fp, "#ifdef EXHAUSTIVE_TEST_ORDER\n");
86 fprintf(fp, "# error Cannot compile precomputed_ecmult.c in exhaustive test mode\n");
87 fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
88 fprintf(fp, "#define WINDOW_G ECMULT_WINDOW_SIZE\n");
89
90 print_two_tables(fp, window_g);
91
92 fprintf(fp, "#undef S\n");
93 fclose(fp);
94
95 return 0;
96}
#define ECMULT_WINDOW_SIZE