Split off .c file from precomputed_ecmult_gen.h
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/***********************************************************************
|
||||
* Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields *
|
||||
* Distributed under the MIT software license, see the accompanying *
|
||||
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
||||
***********************************************************************/
|
||||
/*********************************************************************************
|
||||
* Copyright (c) 2013, 2014, 2015, 2021 Thomas Daede, Cory Fields, Pieter Wuille *
|
||||
* Distributed under the MIT software license, see the accompanying *
|
||||
* file COPYING or https://www.opensource.org/licenses/mit-license.php. *
|
||||
*********************************************************************************/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "ecmult_gen_compute_table_impl.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char outfile[] = "src/precomputed_ecmult_gen.h";
|
||||
const char outfile[] = "src/precomputed_ecmult_gen.c";
|
||||
FILE* fp;
|
||||
int bits;
|
||||
|
||||
@@ -30,19 +30,17 @@ int main(int argc, char **argv) {
|
||||
|
||||
fprintf(fp, "/* This file was automatically generated by precompute_ecmult_gen. */\n");
|
||||
fprintf(fp, "/* See ecmult_gen_impl.h for details about the contents of this file. */\n");
|
||||
fprintf(fp, "#ifndef SECP256K1_PRECOMPUTED_ECMULT_GEN_H\n");
|
||||
fprintf(fp, "#define SECP256K1_PRECOMPUTED_ECMULT_GEN_H\n");
|
||||
|
||||
fprintf(fp, "#if defined HAVE_CONFIG_H\n");
|
||||
fprintf(fp, "#include \"libsecp256k1-config.h\"\n");
|
||||
fprintf(fp, "#endif\n");
|
||||
fprintf(fp, "#include \"../include/secp256k1.h\"\n");
|
||||
fprintf(fp, "#include \"group.h\"\n");
|
||||
|
||||
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");
|
||||
|
||||
fprintf(fp, "#include \"ecmult_gen.h\"\n");
|
||||
fprintf(fp, "#ifdef EXHAUSTIVE_TEST_ORDER\n");
|
||||
fprintf(fp, "static secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N(ECMULT_GEN_PREC_BITS)][ECMULT_GEN_PREC_G(ECMULT_GEN_PREC_BITS)];\n");
|
||||
fprintf(fp, "#else\n");
|
||||
fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N(ECMULT_GEN_PREC_BITS)][ECMULT_GEN_PREC_G(ECMULT_GEN_PREC_BITS)] = {\n");
|
||||
fprintf(fp, "#error Cannot compile precomputed_ecmult_gen.c in exhaustive test mode\n");
|
||||
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
|
||||
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");
|
||||
fprintf(fp, "const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[ECMULT_GEN_PREC_N(ECMULT_GEN_PREC_BITS)][ECMULT_GEN_PREC_G(ECMULT_GEN_PREC_BITS)] = {\n");
|
||||
|
||||
for (bits = 2; bits <= 8; bits *= 2) {
|
||||
int g = ECMULT_GEN_PREC_G(bits);
|
||||
@@ -74,9 +72,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
fprintf(fp, "};\n");
|
||||
fprintf(fp, "#endif /* EXHAUSTIVE_TEST_ORDER */\n");
|
||||
fprintf(fp, "#undef SC\n");
|
||||
fprintf(fp, "#endif /* SECP256K1_PRECOMPUTED_ECMULT_GEN_H */\n");
|
||||
fprintf(fp, "#undef S\n");
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user