Bitcoin Core  0.19.99
P2P Digital Currency
gen_context.c
Go to the documentation of this file.
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 http://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 
7 #define USE_BASIC_CONFIG 1
8 
9 #include "basic-config.h"
10 #include "include/secp256k1.h"
11 #include "field_impl.h"
12 #include "scalar_impl.h"
13 #include "group_impl.h"
14 #include "ecmult_gen_impl.h"
15 
16 static void default_error_callback_fn(const char* str, void* data) {
17  (void)data;
18  fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str);
19  abort();
20 }
21 
24  NULL
25 };
26 
27 int main(int argc, char **argv) {
29  int inner;
30  int outer;
31  FILE* fp;
32 
33  (void)argc;
34  (void)argv;
35 
36  fp = fopen("src/ecmult_static_context.h","w");
37  if (fp == NULL) {
38  fprintf(stderr, "Could not open src/ecmult_static_context.h for writing!\n");
39  return -1;
40  }
41 
42  fprintf(fp, "#ifndef _SECP256K1_ECMULT_STATIC_CONTEXT_\n");
43  fprintf(fp, "#define _SECP256K1_ECMULT_STATIC_CONTEXT_\n");
44  fprintf(fp, "#include \"src/group.h\"\n");
45  fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n");
46  fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_static_context[64][16] = {\n");
47 
49  secp256k1_ecmult_gen_context_build(&ctx, &default_error_callback);
50  for(outer = 0; outer != 64; outer++) {
51  fprintf(fp,"{\n");
52  for(inner = 0; inner != 16; inner++) {
53  fprintf(fp," SC(%uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu)", SECP256K1_GE_STORAGE_CONST_GET((*ctx.prec)[outer][inner]));
54  if (inner != 15) {
55  fprintf(fp,",\n");
56  } else {
57  fprintf(fp,"\n");
58  }
59  }
60  if (outer != 63) {
61  fprintf(fp,"},\n");
62  } else {
63  fprintf(fp,"}\n");
64  }
65  }
66  fprintf(fp,"};\n");
68 
69  fprintf(fp, "#undef SC\n");
70  fprintf(fp, "#endif\n");
71  fclose(fp);
72 
73  return 0;
74 }
static const secp256k1_callback default_error_callback
Definition: gen_context.c:22
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:19
static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context *ctx, const secp256k1_callback *cb)
int main(int argc, char **argv)
Definition: gen_context.c:27
static void default_error_callback_fn(const char *str, void *data)
Definition: gen_context.c:16
static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context *ctx)
static secp256k1_context * ctx
Definition: tests.c:46
#define SECP256K1_GE_STORAGE_CONST_GET(t)
Definition: group.h:41
static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context *ctx)
secp256k1_ge_storage(* prec)[64][16]
Definition: ecmult_gen.h:26