Bitcoin Core  31.0.0
P2P Digital Currency
bench_ecmult.c
Go to the documentation of this file.
1 /***********************************************************************
2  * Copyright (c) 2017 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 #include <stdio.h>
7 #include <stdlib.h>
8 
9 #include "secp256k1.c"
10 #include "../include/secp256k1.h"
11 
12 #include "util.h"
13 #include "hash_impl.h"
14 #include "field_impl.h"
15 #include "group_impl.h"
16 #include "scalar_impl.h"
17 #include "ecmult_impl.h"
18 #include "bench.h"
19 
20 #define POINTS 32768
21 
22 static void help(char **argv, int default_iters) {
23  printf("Benchmark EC multiplication algorithms\n");
24  printf("\n");
25  printf("The default number of iterations for each benchmark is %d. This can be\n", default_iters);
26  printf("customized using the SECP256K1_BENCH_ITERS environment variable.\n");
27  printf("\n");
28  printf("Usage: %s <help|pippenger_wnaf|strauss_wnaf|simple>\n", argv[0]);
29  printf("The output shows the number of multiplied and summed points right after the\n");
30  printf("function name. The letter 'g' indicates that one of the points is the generator.\n");
31  printf("The benchmarks are divided by the number of points.\n");
32  printf("\n");
33  printf("default (ecmult_multi): picks pippenger_wnaf or strauss_wnaf depending on the\n");
34  printf(" batch size\n");
35  printf("pippenger_wnaf: for all batch sizes\n");
36  printf("strauss_wnaf: for all batch sizes\n");
37  printf("simple: multiply and sum each point individually\n");
38 }
39 
40 typedef struct {
41  /* Setup once in advance */
42  secp256k1_context* ctx;
50 
51  /* Changes per benchmark */
52  size_t count;
54 
55  /* Changes per benchmark iteration, used to pick different scalars and pubkeys
56  * in each run. */
57  size_t offset1;
58  size_t offset2;
59 
60  /* Benchmark output. */
63 } bench_data;
64 
65 /* Hashes x into [0, POINTS) twice and store the result in offset1 and offset2. */
66 static void hash_into_offset(bench_data* data, size_t x) {
67  data->offset1 = (x * 0x537b7f6f + 0x8f66a481) % POINTS;
68  data->offset2 = (x * 0x7f6f537b + 0x6a1a8f49) % POINTS;
69 }
70 
71 /* Check correctness of the benchmark by computing
72  * sum(outputs) ?= (sum(scalars_gen) + sum(seckeys)*sum(scalars))*G */
73 static void bench_ecmult_teardown_helper(bench_data* data, size_t* seckey_offset, size_t* scalar_offset, size_t* scalar_gen_offset, int iters) {
74  int i;
75  secp256k1_gej sum_output, tmp;
76  secp256k1_scalar sum_scalars;
77 
78  secp256k1_gej_set_infinity(&sum_output);
79  secp256k1_scalar_set_int(&sum_scalars, 0);
80  for (i = 0; i < iters; ++i) {
81  secp256k1_gej_add_var(&sum_output, &sum_output, &data->output[i], NULL);
82  if (scalar_gen_offset != NULL) {
83  secp256k1_scalar_add(&sum_scalars, &sum_scalars, &data->scalars[(*scalar_gen_offset+i) % POINTS]);
84  }
85  if (seckey_offset != NULL) {
86  secp256k1_scalar s = data->seckeys[(*seckey_offset+i) % POINTS];
87  secp256k1_scalar_mul(&s, &s, &data->scalars[(*scalar_offset+i) % POINTS]);
88  secp256k1_scalar_add(&sum_scalars, &sum_scalars, &s);
89  }
90  }
91  secp256k1_ecmult_gen(&data->ctx->ecmult_gen_ctx, &tmp, &sum_scalars);
92  CHECK(secp256k1_gej_eq_var(&tmp, &sum_output));
93 }
94 
95 static void bench_ecmult_setup(void* arg) {
96  bench_data* data = (bench_data*)arg;
97  /* Re-randomize offset to ensure that we're using different scalars and
98  * group elements in each run. */
99  hash_into_offset(data, data->offset1);
100 }
101 
102 static void bench_ecmult_gen(void* arg, int iters) {
103  bench_data* data = (bench_data*)arg;
104  int i;
105 
106  for (i = 0; i < iters; ++i) {
107  secp256k1_ecmult_gen(&data->ctx->ecmult_gen_ctx, &data->output[i], &data->scalars[(data->offset1+i) % POINTS]);
108  }
109 }
110 
111 static void bench_ecmult_gen_teardown(void* arg, int iters) {
112  bench_data* data = (bench_data*)arg;
113  bench_ecmult_teardown_helper(data, NULL, NULL, &data->offset1, iters);
114 }
115 
116 static void bench_ecmult_const(void* arg, int iters) {
117  bench_data* data = (bench_data*)arg;
118  int i;
119 
120  for (i = 0; i < iters; ++i) {
121  secp256k1_ecmult_const(&data->output[i], &data->pubkeys[(data->offset1+i) % POINTS], &data->scalars[(data->offset2+i) % POINTS]);
122  }
123 }
124 
125 static void bench_ecmult_const_teardown(void* arg, int iters) {
126  bench_data* data = (bench_data*)arg;
127  bench_ecmult_teardown_helper(data, &data->offset1, &data->offset2, NULL, iters);
128 }
129 
130 static void bench_ecmult_const_xonly(void* arg, int iters) {
131  bench_data* data = (bench_data*)arg;
132  int i;
133 
134  for (i = 0; i < iters; ++i) {
135  const secp256k1_ge* pubkey = &data->pubkeys[(data->offset1+i) % POINTS];
136  const secp256k1_scalar* scalar = &data->scalars[(data->offset2+i) % POINTS];
137  int known_on_curve = 1;
138  secp256k1_ecmult_const_xonly(&data->output_xonly[i], &pubkey->x, NULL, scalar, known_on_curve);
139  }
140 }
141 
142 static void bench_ecmult_const_xonly_teardown(void* arg, int iters) {
143  bench_data* data = (bench_data*)arg;
144  int i;
145 
146  /* verify by comparing with x coordinate of regular ecmult result */
147  for (i = 0; i < iters; ++i) {
148  const secp256k1_gej* pubkey_gej = &data->pubkeys_gej[(data->offset1+i) % POINTS];
149  const secp256k1_scalar* scalar = &data->scalars[(data->offset2+i) % POINTS];
150  secp256k1_gej expected_gej;
151  secp256k1_ecmult(&expected_gej, pubkey_gej, scalar, NULL);
152  CHECK(secp256k1_gej_eq_x_var(&data->output_xonly[i], &expected_gej));
153  }
154 }
155 
156 static void bench_ecmult_1p(void* arg, int iters) {
157  bench_data* data = (bench_data*)arg;
158  int i;
159 
160  for (i = 0; i < iters; ++i) {
161  secp256k1_ecmult(&data->output[i], &data->pubkeys_gej[(data->offset1+i) % POINTS], &data->scalars[(data->offset2+i) % POINTS], NULL);
162  }
163 }
164 
165 static void bench_ecmult_1p_teardown(void* arg, int iters) {
166  bench_data* data = (bench_data*)arg;
167  bench_ecmult_teardown_helper(data, &data->offset1, &data->offset2, NULL, iters);
168 }
169 
170 static void bench_ecmult_0p_g(void* arg, int iters) {
171  bench_data* data = (bench_data*)arg;
172  int i;
173 
174  for (i = 0; i < iters; ++i) {
175  secp256k1_ecmult(&data->output[i], NULL, &secp256k1_scalar_zero, &data->scalars[(data->offset1+i) % POINTS]);
176  }
177 }
178 
179 static void bench_ecmult_0p_g_teardown(void* arg, int iters) {
180  bench_data* data = (bench_data*)arg;
181  bench_ecmult_teardown_helper(data, NULL, NULL, &data->offset1, iters);
182 }
183 
184 static void bench_ecmult_1p_g(void* arg, int iters) {
185  bench_data* data = (bench_data*)arg;
186  int i;
187 
188  for (i = 0; i < iters/2; ++i) {
189  secp256k1_ecmult(&data->output[i], &data->pubkeys_gej[(data->offset1+i) % POINTS], &data->scalars[(data->offset2+i) % POINTS], &data->scalars[(data->offset1+i) % POINTS]);
190  }
191 }
192 
193 static void bench_ecmult_1p_g_teardown(void* arg, int iters) {
194  bench_data* data = (bench_data*)arg;
195  bench_ecmult_teardown_helper(data, &data->offset1, &data->offset2, &data->offset1, iters/2);
196 }
197 
198 static void run_ecmult_bench(bench_data* data, int iters) {
199  char str[32];
200  sprintf(str, "ecmult_gen");
202  sprintf(str, "ecmult_const");
204  sprintf(str, "ecmult_const_xonly");
206  /* ecmult with non generator point */
207  sprintf(str, "ecmult_1p");
209  /* ecmult with generator point */
210  sprintf(str, "ecmult_0p_g");
212  /* ecmult with generator and non-generator point. The reported time is per point. */
213  sprintf(str, "ecmult_1p_g");
215 }
216 
217 static int bench_ecmult_multi_callback(secp256k1_scalar* sc, secp256k1_ge* ge, size_t idx, void* arg) {
218  bench_data* data = (bench_data*)arg;
219  if (data->includes_g) ++idx;
220  if (idx == 0) {
221  *sc = data->scalars[data->offset1];
222  *ge = secp256k1_ge_const_g;
223  } else {
224  *sc = data->scalars[(data->offset1 + idx) % POINTS];
225  *ge = data->pubkeys[(data->offset2 + idx - 1) % POINTS];
226  }
227  return 1;
228 }
229 
230 static void bench_ecmult_multi(void* arg, int iters) {
231  bench_data* data = (bench_data*)arg;
232 
233  int includes_g = data->includes_g;
234  int iter;
235  int count = data->count;
236  iters = iters / data->count;
237 
238  for (iter = 0; iter < iters; ++iter) {
239  data->ecmult_multi(&data->ctx->error_callback, data->scratch, &data->output[iter], data->includes_g ? &data->scalars[data->offset1] : NULL, bench_ecmult_multi_callback, arg, count - includes_g);
240  data->offset1 = (data->offset1 + count) % POINTS;
241  data->offset2 = (data->offset2 + count - 1) % POINTS;
242  }
243 }
244 
245 static void bench_ecmult_multi_setup(void* arg) {
246  bench_data* data = (bench_data*)arg;
247  hash_into_offset(data, data->count);
248 }
249 
250 static void bench_ecmult_multi_teardown(void* arg, int iters) {
251  bench_data* data = (bench_data*)arg;
252  int iter;
253  iters = iters / data->count;
254  /* Verify the results in teardown, to avoid doing comparisons while benchmarking. */
255  for (iter = 0; iter < iters; ++iter) {
256  secp256k1_gej tmp;
257  secp256k1_gej_add_var(&tmp, &data->output[iter], &data->expected_output[iter], NULL);
259  }
260 }
261 
262 static void generate_scalar(uint32_t num, secp256k1_scalar* scalar) {
264  unsigned char c[10] = {'e', 'c', 'm', 'u', 'l', 't', 0, 0, 0, 0};
265  unsigned char buf[32];
266  int overflow = 0;
267  c[6] = num;
268  c[7] = num >> 8;
269  c[8] = num >> 16;
270  c[9] = num >> 24;
272  secp256k1_sha256_write(&sha256, c, sizeof(c));
274  secp256k1_scalar_set_b32(scalar, buf, &overflow);
275  CHECK(!overflow);
276 }
277 
278 static void run_ecmult_multi_bench(bench_data* data, size_t count, int includes_g, int num_iters) {
279  char str[32];
280  size_t iters = 1 + num_iters / count;
281  size_t iter;
282 
283  data->count = count;
284  data->includes_g = includes_g;
285 
286  /* Compute (the negation of) the expected results directly. */
287  hash_into_offset(data, data->count);
288  for (iter = 0; iter < iters; ++iter) {
289  secp256k1_scalar tmp;
290  secp256k1_scalar total = data->scalars[(data->offset1++) % POINTS];
291  size_t i = 0;
292  for (i = 0; i + 1 < count; ++i) {
293  secp256k1_scalar_mul(&tmp, &data->seckeys[(data->offset2++) % POINTS], &data->scalars[(data->offset1++) % POINTS]);
294  secp256k1_scalar_add(&total, &total, &tmp);
295  }
296  secp256k1_scalar_negate(&total, &total);
297  secp256k1_ecmult(&data->expected_output[iter], NULL, &secp256k1_scalar_zero, &total);
298  }
299 
300  /* Run the benchmark. */
301  if (includes_g) {
302  sprintf(str, "ecmult_multi_%ip_g", (int)count - 1);
303  } else {
304  sprintf(str, "ecmult_multi_%ip", (int)count);
305  }
307 }
308 
309 int main(int argc, char **argv) {
311  int i, p;
312  size_t scratch_size;
313 
314  int default_iters = 10000;
315  int iters = get_iters(default_iters);
316  if (iters == 0) {
317  help(argv, default_iters);
318  return EXIT_FAILURE;
319  }
320 
321  data.ecmult_multi = secp256k1_ecmult_multi_var;
322 
323  if (argc > 1) {
324  if(have_flag(argc, argv, "-h")
325  || have_flag(argc, argv, "--help")
326  || have_flag(argc, argv, "help")) {
327  help(argv, default_iters);
328  return EXIT_SUCCESS;
329  } else if(have_flag(argc, argv, "pippenger_wnaf")) {
330  printf("Using pippenger_wnaf:\n");
332  } else if(have_flag(argc, argv, "strauss_wnaf")) {
333  printf("Using strauss_wnaf:\n");
335  } else if(have_flag(argc, argv, "simple")) {
336  printf("Using simple algorithm:\n");
337  } else {
338  fprintf(stderr, "%s: unrecognized argument '%s'.\n\n", argv[0], argv[1]);
339  help(argv, default_iters);
340  return EXIT_FAILURE;
341  }
342  }
343 
346  if (!have_flag(argc, argv, "simple")) {
347  data.scratch = secp256k1_scratch_space_create(data.ctx, scratch_size);
348  } else {
349  data.scratch = NULL;
350  }
351 
352  /* Allocate stuff */
353  data.scalars = malloc(sizeof(secp256k1_scalar) * POINTS);
354  data.seckeys = malloc(sizeof(secp256k1_scalar) * POINTS);
355  data.pubkeys = malloc(sizeof(secp256k1_ge) * POINTS);
356  data.pubkeys_gej = malloc(sizeof(secp256k1_gej) * POINTS);
357  data.expected_output = malloc(sizeof(secp256k1_gej) * (iters + 1));
358  data.output = malloc(sizeof(secp256k1_gej) * (iters + 1));
359  data.output_xonly = malloc(sizeof(secp256k1_fe) * (iters + 1));
360 
361  /* Generate a set of scalars, and private/public keypairs. */
363  secp256k1_scalar_set_int(&data.seckeys[0], 1);
364  for (i = 0; i < POINTS; ++i) {
365  generate_scalar(i, &data.scalars[i]);
366  if (i) {
367  secp256k1_gej_double_var(&data.pubkeys_gej[i], &data.pubkeys_gej[i - 1], NULL);
368  secp256k1_scalar_add(&data.seckeys[i], &data.seckeys[i - 1], &data.seckeys[i - 1]);
369  }
370  }
371  secp256k1_ge_set_all_gej_var(data.pubkeys, data.pubkeys_gej, POINTS);
372 
373 
375  /* Initialize offset1 and offset2 */
376  hash_into_offset(&data, 0);
377  run_ecmult_bench(&data, iters);
378 
379  for (i = 1; i <= 8; ++i) {
380  run_ecmult_multi_bench(&data, i, 1, iters);
381  }
382 
383  /* This is disabled with low count of iterations because the loop runs 77 times even with iters=1
384  * and the higher it goes the longer the computation takes(more points)
385  * So we don't run this benchmark with low iterations to prevent slow down */
386  if (iters > 2) {
387  for (p = 0; p <= 11; ++p) {
388  for (i = 9; i <= 16; ++i) {
389  run_ecmult_multi_bench(&data, i << p, 1, iters);
390  }
391  }
392  } else {
393  printf("Skipping some benchmarks due to SECP256K1_BENCH_ITERS <= 2\n");
394  }
395 
396  if (data.scratch != NULL) {
398  }
400  free(data.scalars);
401  free(data.pubkeys);
402  free(data.pubkeys_gej);
403  free(data.seckeys);
404  free(data.output_xonly);
405  free(data.output);
406  free(data.expected_output);
407 
408  return EXIT_SUCCESS;
409 }
static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Multiply two scalars (modulo the group order).
static int secp256k1_gej_is_infinity(const secp256k1_gej *a)
Check whether a group element is the point at infinity.
This field implementation represents the value as 10 uint32_t limbs in base 2^26. ...
Definition: field_10x26.h:14
size_t count
Definition: bench_ecmult.c:52
static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr)
Set r equal to the sum of a and b.
static int secp256k1_ecmult_pippenger_batch_single(const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
Definition: ecmult_impl.h:734
static void bench_ecmult_1p_teardown(void *arg, int iters)
Definition: bench_ecmult.c:165
return EXIT_SUCCESS
int(* secp256k1_ecmult_multi_func)(const secp256k1_callback *error_callback, secp256k1_scratch *, secp256k1_gej *, const secp256k1_scalar *, secp256k1_ecmult_multi_callback cb, void *, size_t)
Definition: ecmult_impl.h:822
secp256k1_gej * expected_output
Definition: bench_ecmult.c:48
static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *a)
Multiply with the generator: R = a*G.
#define ALIGNMENT
Definition: util.h:176
static void bench_ecmult_teardown_helper(bench_data *data, size_t *seckey_offset, size_t *scalar_offset, size_t *scalar_gen_offset, int iters)
Definition: bench_ecmult.c:73
static void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space *scratch)
Definition: secp256k1.c:228
secp256k1_scalar * scalars
Definition: bench_ecmult.c:44
static void bench_ecmult_0p_g(void *arg, int iters)
Definition: bench_ecmult.c:170
static void bench_ecmult_1p(void *arg, int iters)
Definition: bench_ecmult.c:156
#define SECP256K1_CONTEXT_NONE
Context flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context_preallocated_create.
Definition: secp256k1.h:214
static void run_benchmark(char *name, void(*benchmark)(void *), void(*setup)(void *), void(*teardown)(void *), void *data, int count, int iter)
Definition: bench.c:26
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
Set group elements r[0:len] (affine) equal to group elements a[0:len] (jacobian). ...
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 context object (created in dynamically allocated memory).
Definition: secp256k1.c:187
secp256k1_gej * pubkeys_gej
Definition: bench_ecmult.c:46
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q)
Multiply: R = q*A (in constant-time for q)
static void bench_ecmult_const_xonly(void *arg, int iters)
Definition: bench_ecmult.c:130
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow)
Set a scalar from a big endian byte array.
A group element of the secp256k1 curve, in jacobian coordinates.
Definition: group.h:28
static void hash_into_offset(bench_data *data, size_t x)
Definition: bench_ecmult.c:66
size_t offset2
Definition: bench_ecmult.c:58
#define POINTS
Definition: bench_ecmult.c:20
static void secp256k1_gej_set_infinity(secp256k1_gej *r)
Set a group element (jacobian) equal to the point at infinity.
static void bench_ecmult_gen_teardown(void *arg, int iters)
Definition: bench_ecmult.c:111
static const secp256k1_scalar secp256k1_scalar_zero
Definition: scalar_impl.h:28
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
Set r equal to the double of a.
static void run_ecmult_multi_bench(bench_data *data, size_t count, int includes_g, int num_iters)
Definition: bench_ecmult.c:278
static void secp256k1_ecmult(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng)
Double multiply: R = na*A + ng*G.
static int secp256k1_ecmult_const_xonly(secp256k1_fe *r, const secp256k1_fe *n, const secp256k1_fe *d, const secp256k1_scalar *q, int known_on_curve)
Same as secp256k1_ecmult_const, but takes in an x coordinate of the base point only, specified as fraction n/d (numerator/denominator).
static const secp256k1_ge secp256k1_ge_const_g
Definition: group_impl.h:72
secp256k1_fe * output_xonly
Definition: bench_ecmult.c:62
static void bench_ecmult_multi(void *arg, int iters)
Definition: bench_ecmult.c:230
secp256k1_scratch_space * scratch
Definition: bench_ecmult.c:43
static secp256k1_scratch_space * secp256k1_scratch_space_create(const secp256k1_context *ctx, size_t max_size)
Definition: secp256k1.c:223
secp256k1_ecmult_multi_func ecmult_multi
Definition: bench_ecmult.c:49
static int get_iters(int default_iters)
Definition: bench.h:150
secp256k1_scalar * seckeys
Definition: bench_ecmult.c:47
static int secp256k1_ecmult_strauss_batch_single(const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
Definition: ecmult_impl.h:422
static void bench_ecmult_const_teardown(void *arg, int iters)
Definition: bench_ecmult.c:125
static int have_flag(int argc, char **argv, char *flag)
Definition: bench.h:112
static void bench_ecmult_const_xonly_teardown(void *arg, int iters)
Definition: bench_ecmult.c:142
static void bench_ecmult_1p_g(void *arg, int iters)
Definition: bench_ecmult.c:184
#define CHECK(cond)
Unconditional failure on condition failure.
Definition: util.h:35
static int secp256k1_ecmult_multi_var(const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai.
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
Definition: group.h:16
secp256k1_fe x
Definition: group.h:17
static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a)
Compare the X coordinate of a group element (jacobian).
static size_t secp256k1_strauss_scratch_size(size_t n_points)
Definition: ecmult_impl.h:377
static void bench_ecmult_multi_setup(void *arg)
Definition: bench_ecmult.c:245
static void run_ecmult_bench(bench_data *data, int iters)
Definition: bench_ecmult.c:198
A scalar modulo the group order of the secp256k1 curve.
Definition: scalar_4x64.h:13
#define STRAUSS_SCRATCH_OBJECTS
Definition: ecmult_impl.h:50
static void bench_ecmult_gen(void *arg, int iters)
Definition: bench_ecmult.c:102
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
static void generate_scalar(uint32_t num, secp256k1_scalar *scalar)
Definition: bench_ecmult.c:262
static void bench_ecmult_0p_g_teardown(void *arg, int iters)
Definition: bench_ecmult.c:179
secp256k1_ge * pubkeys
Definition: bench_ecmult.c:45
static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Add two scalars together (modulo the group order).
int main(int argc, char **argv)
Definition: bench_ecmult.c:309
static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v)
Set a scalar to an unsigned integer.
static void bench_ecmult_1p_g_teardown(void *arg, int iters)
Definition: bench_ecmult.c:193
static void bench_ecmult_const(void *arg, int iters)
Definition: bench_ecmult.c:116
static void help(char **argv, int default_iters)
Definition: bench_ecmult.c:22
Internal SHA-256 implementation.
Definition: sha256.cpp:67
secp256k1_gej * output
Definition: bench_ecmult.c:61
static int count
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
static void print_output_table_header_row(void)
Definition: bench.h:165
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
Set a group element (jacobian) equal to another which is given in affine coordinates.
void printf(FormatStringCheck< sizeof...(Args)> fmt, const Args &... args)
Format list of arguments to std::cout, according to the given format string.
Definition: tinyformat.h:1096
size_t offset1
Definition: bench_ecmult.c:57
int includes_g
Definition: bench_ecmult.c:53
static void bench_ecmult_multi_teardown(void *arg, int iters)
Definition: bench_ecmult.c:250
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
Definition: secp256k1.c:141
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
static int bench_ecmult_multi_callback(secp256k1_scalar *sc, secp256k1_ge *ge, size_t idx, void *arg)
Definition: bench_ecmult.c:217
static void bench_ecmult_setup(void *arg)
Definition: bench_ecmult.c:95
static int secp256k1_gej_eq_var(const secp256k1_gej *a, const secp256k1_gej *b)
Check two group elements (jacobian) for equality in variable time.