1
- /***********************************************************************
2
- * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields *
3
- * Distributed under the MIT software license, see the accompanying *
4
- * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5
- ***********************************************************************/
1
+ /*********************************************************************************
2
+ * Copyright (c) 2013, 2014, 2015, 2021 Thomas Daede, Cory Fields, Pieter Wuille *
3
+ * Distributed under the MIT software license, see the accompanying *
4
+ * file COPYING or https://www.opensource.org/licenses/mit-license.php. *
5
+ ********************************************************************************* /
6
6
7
7
#include <inttypes.h>
8
8
#include <stdio.h>
15
15
#include "ecmult_gen_compute_table_impl.h"
16
16
17
17
int main (int argc , char * * argv ) {
18
- const char outfile [] = "src/precomputed_ecmult_gen.h " ;
18
+ const char outfile [] = "src/precomputed_ecmult_gen.c " ;
19
19
FILE * fp ;
20
20
int bits ;
21
21
@@ -30,19 +30,17 @@ int main(int argc, char **argv) {
30
30
31
31
fprintf (fp , "/* This file was automatically generated by precompute_ecmult_gen. */\n" );
32
32
fprintf (fp , "/* See ecmult_gen_impl.h for details about the contents of this file. */\n" );
33
- fprintf (fp , "#ifndef SECP256K1_PRECOMPUTED_ECMULT_GEN_H\n" );
34
- fprintf (fp , "#define SECP256K1_PRECOMPUTED_ECMULT_GEN_H\n" );
35
-
33
+ fprintf (fp , "#if defined HAVE_CONFIG_H\n" );
34
+ fprintf (fp , "#include \"libsecp256k1-config.h\"\n" );
35
+ fprintf (fp , "#endif\n" );
36
+ fprintf (fp , "#include \"../include/secp256k1.h\"\n" );
36
37
fprintf (fp , "#include \"group.h\"\n" );
37
-
38
- fprintf (fp , "#define S(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) "
39
- "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,"
40
- "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" );
41
-
38
+ fprintf (fp , "#include \"ecmult_gen.h\"\n" );
42
39
fprintf (fp , "#ifdef EXHAUSTIVE_TEST_ORDER\n" );
43
- 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" );
44
- fprintf (fp , "#else\n" );
45
- 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" );
40
+ fprintf (fp , "#error Cannot compile precomputed_ecmult_gen.c in exhaustive test mode\n" );
41
+ fprintf (fp , "#endif /* EXHAUSTIVE_TEST_ORDER */\n" );
42
+ 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" );
43
+ 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" );
46
44
47
45
for (bits = 2 ; bits <= 8 ; bits *= 2 ) {
48
46
int g = ECMULT_GEN_PREC_G (bits );
@@ -74,9 +72,7 @@ int main(int argc, char **argv) {
74
72
}
75
73
76
74
fprintf (fp , "};\n" );
77
- fprintf (fp , "#endif /* EXHAUSTIVE_TEST_ORDER */\n" );
78
- fprintf (fp , "#undef SC\n" );
79
- fprintf (fp , "#endif /* SECP256K1_PRECOMPUTED_ECMULT_GEN_H */\n" );
75
+ fprintf (fp , "#undef S\n" );
80
76
fclose (fp );
81
77
82
78
return 0 ;
0 commit comments