Bitcoin Core  0.20.99
P2P Digital Currency
bench_internal.c
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (c) 2014-2015 Pieter Wuille *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 #include <stdio.h>
7 
8 #include "include/secp256k1.h"
9 
10 #include "util.h"
11 #include "hash_impl.h"
12 #include "num_impl.h"
13 #include "field_impl.h"
14 #include "group_impl.h"
15 #include "scalar_impl.h"
16 #include "ecmult_const_impl.h"
17 #include "ecmult_impl.h"
18 #include "bench.h"
19 #include "secp256k1.c"
20 
21 typedef struct {
26  unsigned char data[64];
27  int wnaf[256];
28 } bench_inv;
29 
30 void bench_setup(void* arg) {
31  bench_inv *data = (bench_inv*)arg;
32 
33  static const unsigned char init_x[32] = {
34  0x02, 0x03, 0x05, 0x07, 0x0b, 0x0d, 0x11, 0x13,
35  0x17, 0x1d, 0x1f, 0x25, 0x29, 0x2b, 0x2f, 0x35,
36  0x3b, 0x3d, 0x43, 0x47, 0x49, 0x4f, 0x53, 0x59,
37  0x61, 0x65, 0x67, 0x6b, 0x6d, 0x71, 0x7f, 0x83
38  };
39 
40  static const unsigned char init_y[32] = {
41  0x82, 0x83, 0x85, 0x87, 0x8b, 0x8d, 0x81, 0x83,
42  0x97, 0xad, 0xaf, 0xb5, 0xb9, 0xbb, 0xbf, 0xc5,
43  0xdb, 0xdd, 0xe3, 0xe7, 0xe9, 0xef, 0xf3, 0xf9,
44  0x11, 0x15, 0x17, 0x1b, 0x1d, 0xb1, 0xbf, 0xd3
45  };
46 
47  secp256k1_scalar_set_b32(&data->scalar_x, init_x, NULL);
48  secp256k1_scalar_set_b32(&data->scalar_y, init_y, NULL);
49  secp256k1_fe_set_b32(&data->fe_x, init_x);
50  secp256k1_fe_set_b32(&data->fe_y, init_y);
51  CHECK(secp256k1_ge_set_xo_var(&data->ge_x, &data->fe_x, 0));
52  CHECK(secp256k1_ge_set_xo_var(&data->ge_y, &data->fe_y, 1));
53  secp256k1_gej_set_ge(&data->gej_x, &data->ge_x);
54  secp256k1_gej_set_ge(&data->gej_y, &data->ge_y);
55  memcpy(data->data, init_x, 32);
56  memcpy(data->data + 32, init_y, 32);
57 }
58 
59 void bench_scalar_add(void* arg, int iters) {
60  int i, j = 0;
61  bench_inv *data = (bench_inv*)arg;
62 
63  for (i = 0; i < iters; i++) {
64  j += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
65  }
66  CHECK(j <= iters);
67 }
68 
69 void bench_scalar_negate(void* arg, int iters) {
70  int i;
71  bench_inv *data = (bench_inv*)arg;
72 
73  for (i = 0; i < iters; i++) {
75  }
76 }
77 
78 void bench_scalar_sqr(void* arg, int iters) {
79  int i;
80  bench_inv *data = (bench_inv*)arg;
81 
82  for (i = 0; i < iters; i++) {
83  secp256k1_scalar_sqr(&data->scalar_x, &data->scalar_x);
84  }
85 }
86 
87 void bench_scalar_mul(void* arg, int iters) {
88  int i;
89  bench_inv *data = (bench_inv*)arg;
90 
91  for (i = 0; i < iters; i++) {
92  secp256k1_scalar_mul(&data->scalar_x, &data->scalar_x, &data->scalar_y);
93  }
94 }
95 
96 #ifdef USE_ENDOMORPHISM
97 void bench_scalar_split(void* arg, int iters) {
98  int i, j = 0;
99  bench_inv *data = (bench_inv*)arg;
100 
101  for (i = 0; i < iters; i++) {
102  secp256k1_scalar_split_lambda(&data->scalar_x, &data->scalar_y, &data->scalar_x);
103  j += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
104  }
105  CHECK(j <= iters);
106 }
107 #endif
108 
109 void bench_scalar_inverse(void* arg, int iters) {
110  int i, j = 0;
111  bench_inv *data = (bench_inv*)arg;
112 
113  for (i = 0; i < iters; i++) {
115  j += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
116  }
117  CHECK(j <= iters);
118 }
119 
120 void bench_scalar_inverse_var(void* arg, int iters) {
121  int i, j = 0;
122  bench_inv *data = (bench_inv*)arg;
123 
124  for (i = 0; i < iters; i++) {
126  j += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
127  }
128  CHECK(j <= iters);
129 }
130 
131 void bench_field_normalize(void* arg, int iters) {
132  int i;
133  bench_inv *data = (bench_inv*)arg;
134 
135  for (i = 0; i < iters; i++) {
137  }
138 }
139 
140 void bench_field_normalize_weak(void* arg, int iters) {
141  int i;
142  bench_inv *data = (bench_inv*)arg;
143 
144  for (i = 0; i < iters; i++) {
146  }
147 }
148 
149 void bench_field_mul(void* arg, int iters) {
150  int i;
151  bench_inv *data = (bench_inv*)arg;
152 
153  for (i = 0; i < iters; i++) {
154  secp256k1_fe_mul(&data->fe_x, &data->fe_x, &data->fe_y);
155  }
156 }
157 
158 void bench_field_sqr(void* arg, int iters) {
159  int i;
160  bench_inv *data = (bench_inv*)arg;
161 
162  for (i = 0; i < iters; i++) {
163  secp256k1_fe_sqr(&data->fe_x, &data->fe_x);
164  }
165 }
166 
167 void bench_field_inverse(void* arg, int iters) {
168  int i;
169  bench_inv *data = (bench_inv*)arg;
170 
171  for (i = 0; i < iters; i++) {
172  secp256k1_fe_inv(&data->fe_x, &data->fe_x);
173  secp256k1_fe_add(&data->fe_x, &data->fe_y);
174  }
175 }
176 
177 void bench_field_inverse_var(void* arg, int iters) {
178  int i;
179  bench_inv *data = (bench_inv*)arg;
180 
181  for (i = 0; i < iters; i++) {
182  secp256k1_fe_inv_var(&data->fe_x, &data->fe_x);
183  secp256k1_fe_add(&data->fe_x, &data->fe_y);
184  }
185 }
186 
187 void bench_field_sqrt(void* arg, int iters) {
188  int i, j = 0;
189  bench_inv *data = (bench_inv*)arg;
190  secp256k1_fe t;
191 
192  for (i = 0; i < iters; i++) {
193  t = data->fe_x;
194  j += secp256k1_fe_sqrt(&data->fe_x, &t);
195  secp256k1_fe_add(&data->fe_x, &data->fe_y);
196  }
197  CHECK(j <= iters);
198 }
199 
200 void bench_group_double_var(void* arg, int iters) {
201  int i;
202  bench_inv *data = (bench_inv*)arg;
203 
204  for (i = 0; i < iters; i++) {
205  secp256k1_gej_double_var(&data->gej_x, &data->gej_x, NULL);
206  }
207 }
208 
209 void bench_group_add_var(void* arg, int iters) {
210  int i;
211  bench_inv *data = (bench_inv*)arg;
212 
213  for (i = 0; i < iters; i++) {
214  secp256k1_gej_add_var(&data->gej_x, &data->gej_x, &data->gej_y, NULL);
215  }
216 }
217 
218 void bench_group_add_affine(void* arg, int iters) {
219  int i;
220  bench_inv *data = (bench_inv*)arg;
221 
222  for (i = 0; i < iters; i++) {
223  secp256k1_gej_add_ge(&data->gej_x, &data->gej_x, &data->ge_y);
224  }
225 }
226 
227 void bench_group_add_affine_var(void* arg, int iters) {
228  int i;
229  bench_inv *data = (bench_inv*)arg;
230 
231  for (i = 0; i < iters; i++) {
232  secp256k1_gej_add_ge_var(&data->gej_x, &data->gej_x, &data->ge_y, NULL);
233  }
234 }
235 
236 void bench_group_jacobi_var(void* arg, int iters) {
237  int i, j = 0;
238  bench_inv *data = (bench_inv*)arg;
239 
240  for (i = 0; i < iters; i++) {
241  j += secp256k1_gej_has_quad_y_var(&data->gej_x);
242  }
243  CHECK(j == iters);
244 }
245 
246 void bench_ecmult_wnaf(void* arg, int iters) {
247  int i, bits = 0, overflow = 0;
248  bench_inv *data = (bench_inv*)arg;
249 
250  for (i = 0; i < iters; i++) {
251  bits += secp256k1_ecmult_wnaf(data->wnaf, 256, &data->scalar_x, WINDOW_A);
252  overflow += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
253  }
254  CHECK(overflow >= 0);
255  CHECK(bits <= 256*iters);
256 }
257 
258 void bench_wnaf_const(void* arg, int iters) {
259  int i, bits = 0, overflow = 0;
260  bench_inv *data = (bench_inv*)arg;
261 
262  for (i = 0; i < iters; i++) {
263  bits += secp256k1_wnaf_const(data->wnaf, &data->scalar_x, WINDOW_A, 256);
264  overflow += secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
265  }
266  CHECK(overflow >= 0);
267  CHECK(bits <= 256*iters);
268 }
269 
270 
271 void bench_sha256(void* arg, int iters) {
272  int i;
273  bench_inv *data = (bench_inv*)arg;
274  secp256k1_sha256 sha;
275 
276  for (i = 0; i < iters; i++) {
278  secp256k1_sha256_write(&sha, data->data, 32);
279  secp256k1_sha256_finalize(&sha, data->data);
280  }
281 }
282 
283 void bench_hmac_sha256(void* arg, int iters) {
284  int i;
285  bench_inv *data = (bench_inv*)arg;
287 
288  for (i = 0; i < iters; i++) {
289  secp256k1_hmac_sha256_initialize(&hmac, data->data, 32);
290  secp256k1_hmac_sha256_write(&hmac, data->data, 32);
291  secp256k1_hmac_sha256_finalize(&hmac, data->data);
292  }
293 }
294 
295 void bench_rfc6979_hmac_sha256(void* arg, int iters) {
296  int i;
297  bench_inv *data = (bench_inv*)arg;
299 
300  for (i = 0; i < iters; i++) {
303  }
304 }
305 
306 void bench_context_verify(void* arg, int iters) {
307  int i;
308  (void)arg;
309  for (i = 0; i < iters; i++) {
311  }
312 }
313 
314 void bench_context_sign(void* arg, int iters) {
315  int i;
316  (void)arg;
317  for (i = 0; i < iters; i++) {
319  }
320 }
321 
322 #ifndef USE_NUM_NONE
323 void bench_num_jacobi(void* arg, int iters) {
324  int i, j = 0;
325  bench_inv *data = (bench_inv*)arg;
326  secp256k1_num nx, norder;
327 
328  secp256k1_scalar_get_num(&nx, &data->scalar_x);
330  secp256k1_scalar_get_num(&norder, &data->scalar_y);
331 
332  for (i = 0; i < iters; i++) {
333  j += secp256k1_num_jacobi(&nx, &norder);
334  }
335  CHECK(j <= iters);
336 }
337 #endif
338 
339 int main(int argc, char **argv) {
340  bench_inv data;
341  int iters = get_iters(20000);
342 
343  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "add")) run_benchmark("scalar_add", bench_scalar_add, bench_setup, NULL, &data, 10, iters*100);
344  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "negate")) run_benchmark("scalar_negate", bench_scalar_negate, bench_setup, NULL, &data, 10, iters*100);
345  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "sqr")) run_benchmark("scalar_sqr", bench_scalar_sqr, bench_setup, NULL, &data, 10, iters*10);
346  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "mul")) run_benchmark("scalar_mul", bench_scalar_mul, bench_setup, NULL, &data, 10, iters*10);
347 #ifdef USE_ENDOMORPHISM
348  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "split")) run_benchmark("scalar_split", bench_scalar_split, bench_setup, NULL, &data, 10, iters);
349 #endif
350  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "inverse")) run_benchmark("scalar_inverse", bench_scalar_inverse, bench_setup, NULL, &data, 10, 2000);
351  if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "inverse")) run_benchmark("scalar_inverse_var", bench_scalar_inverse_var, bench_setup, NULL, &data, 10, 2000);
352 
353  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "normalize")) run_benchmark("field_normalize", bench_field_normalize, bench_setup, NULL, &data, 10, iters*100);
354  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "normalize")) run_benchmark("field_normalize_weak", bench_field_normalize_weak, bench_setup, NULL, &data, 10, iters*100);
355  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "sqr")) run_benchmark("field_sqr", bench_field_sqr, bench_setup, NULL, &data, 10, iters*10);
356  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "mul")) run_benchmark("field_mul", bench_field_mul, bench_setup, NULL, &data, 10, iters*10);
357  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "inverse")) run_benchmark("field_inverse", bench_field_inverse, bench_setup, NULL, &data, 10, iters);
358  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "inverse")) run_benchmark("field_inverse_var", bench_field_inverse_var, bench_setup, NULL, &data, 10, iters);
359  if (have_flag(argc, argv, "field") || have_flag(argc, argv, "sqrt")) run_benchmark("field_sqrt", bench_field_sqrt, bench_setup, NULL, &data, 10, iters);
360 
361  if (have_flag(argc, argv, "group") || have_flag(argc, argv, "double")) run_benchmark("group_double_var", bench_group_double_var, bench_setup, NULL, &data, 10, iters*10);
362  if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_var", bench_group_add_var, bench_setup, NULL, &data, 10, iters*10);
363  if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_affine", bench_group_add_affine, bench_setup, NULL, &data, 10, iters*10);
364  if (have_flag(argc, argv, "group") || have_flag(argc, argv, "add")) run_benchmark("group_add_affine_var", bench_group_add_affine_var, bench_setup, NULL, &data, 10, iters*10);
365  if (have_flag(argc, argv, "group") || have_flag(argc, argv, "jacobi")) run_benchmark("group_jacobi_var", bench_group_jacobi_var, bench_setup, NULL, &data, 10, iters);
366 
367  if (have_flag(argc, argv, "ecmult") || have_flag(argc, argv, "wnaf")) run_benchmark("wnaf_const", bench_wnaf_const, bench_setup, NULL, &data, 10, iters);
368  if (have_flag(argc, argv, "ecmult") || have_flag(argc, argv, "wnaf")) run_benchmark("ecmult_wnaf", bench_ecmult_wnaf, bench_setup, NULL, &data, 10, iters);
369 
370  if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "sha256")) run_benchmark("hash_sha256", bench_sha256, bench_setup, NULL, &data, 10, iters);
371  if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "hmac")) run_benchmark("hash_hmac_sha256", bench_hmac_sha256, bench_setup, NULL, &data, 10, iters);
372  if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "rng6979")) run_benchmark("hash_rfc6979_hmac_sha256", bench_rfc6979_hmac_sha256, bench_setup, NULL, &data, 10, iters);
373 
374  if (have_flag(argc, argv, "context") || have_flag(argc, argv, "verify")) run_benchmark("context_verify", bench_context_verify, bench_setup, NULL, &data, 10, 1 + iters/1000);
375  if (have_flag(argc, argv, "context") || have_flag(argc, argv, "sign")) run_benchmark("context_sign", bench_context_sign, bench_setup, NULL, &data, 10, 1 + iters/100);
376 
377 #ifndef USE_NUM_NONE
378  if (have_flag(argc, argv, "num") || have_flag(argc, argv, "jacobi")) run_benchmark("num_jacobi", bench_num_jacobi, bench_setup, NULL, &data, 10, iters*10);
379 #endif
380  return 0;
381 }
static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Multiply two scalars (modulo the group order).
void bench_field_sqrt(void *arg, int iters)
secp256k1_fe fe_y
void bench_rfc6979_hmac_sha256(void *arg, int iters)
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_gej_has_quad_y_var(const secp256k1_gej *a)
Check whether a group element&#39;s y coordinate is a quadratic residue.
static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe *SECP256K1_RESTRICT b)
Sets a field element to be the product of two others.
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen)
static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a)
Convert a scalar to a number.
secp256k1_scalar scalar_x
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const unsigned char *key, size_t size)
secp256k1_ge ge_y
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
void bench_scalar_inverse_var(void *arg, int iters)
void run_benchmark(char *name, void(*benchmark)(void *, int), void(*setup)(void *), void(*teardown)(void *, int), void *data, int count, int iter)
Definition: bench.h:76
void bench_ecmult_wnaf(void *arg, int iters)
void bench_scalar_inverse(void *arg, int iters)
static int secp256k1_wnaf_const(int *wnaf, const secp256k1_scalar *scalar, int w, int size)
Convert a number to WNAF notation.
void bench_group_add_affine(void *arg, int iters)
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:24
void bench_field_inverse(void *arg, int iters)
#define SECP256K1_CONTEXT_SIGN
Definition: secp256k1.h:171
static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a)
Adds a field element to another.
static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
Set r equal to the sum of a and b (with b given in affine coordinates).
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
Set r equal to the double of a.
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object (created in dynamically allocated memory).
Definition: secp256k1.c:190
secp256k1_scalar scalar_y
static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the inverse of a scalar (modulo the group order).
secp256k1_ge ge_x
void bench_scalar_negate(void *arg, int iters)
secp256k1_gej gej_y
static int secp256k1_num_jacobi(const secp256k1_num *a, const secp256k1_num *b)
Compute the jacobi symbol (a|b).
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256 *hash, const unsigned char *data, size_t size)
static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the square of a scalar (modulo the group order).
void bench_group_add_affine_var(void *arg, int iters)
secp256k1_fe fe_x
void bench_scalar_sqr(void *arg, int iters)
A group element of the secp256k1 curve, in affine coordinates.
Definition: group.h:14
static void secp256k1_fe_normalize_weak(secp256k1_fe *r)
Weakly normalize a field element: reduce its magnitude to 1, but don&#39;t fully normalize.
void bench_field_mul(void *arg, int iters)
static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256 *hash, unsigned char *out32)
void bench_field_sqr(void *arg, int iters)
#define CHECK(cond)
Definition: util.h:53
A scalar modulo the group order of the secp256k1 curve.
Definition: scalar_4x64.h:13
#define WINDOW_A
Definition: ecmult_impl.h:34
void bench_group_jacobi_var(void *arg, int iters)
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd)
Set a group element (affine) equal to the point with the given X coordinate, and given oddness for Y...
static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the square of another.
static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a)
Set a field element equal to 32-byte big endian value.
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
Definition: secp256k1.h:170
void bench_field_normalize_weak(void *arg, int iters)
unsigned char data[64]
static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Add two scalars together (modulo the group order).
static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the inverse of a scalar (modulo the group order), without constant-time guarantee.
void * memcpy(void *a, const void *b, size_t c)
void bench_wnaf_const(void *arg, int iters)
static void secp256k1_fe_normalize(secp256k1_fe *r)
Field element module.
void bench_field_normalize(void *arg, int iters)
void bench_field_inverse_var(void *arg, int iters)
void bench_context_sign(void *arg, int iters)
int get_iters(int default_iters)
Definition: bench.h:124
void bench_setup(void *arg)
void bench_context_verify(void *arg, int iters)
int wnaf[256]
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
Set r equal to the sum of a and b (with b given in affine coordinates, and not infinity).
void bench_hmac_sha256(void *arg, int iters)
int main(int argc, char **argv)
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
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 bench_sha256(void *arg, int iters)
static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w)
Convert a number to WNAF notation.
Definition: ecmult_impl.h:397
static void secp256k1_scalar_order_get_num(secp256k1_num *r)
Get the order of the group as a number.
static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a)
If a has a square root, it is computed in r and 1 is returned.
static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a)
Potentially faster version of secp256k1_fe_inv, without constant-time guarantee.
void bench_scalar_mul(void *arg, int iters)
int have_flag(int argc, char **argv, char *flag)
Definition: bench.h:109
static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the (modular) inverse of another.
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:146
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
void bench_group_add_var(void *arg, int iters)
secp256k1_gej gej_x
void bench_group_double_var(void *arg, int iters)
void bench_num_jacobi(void *arg, int iters)
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen)
void bench_scalar_add(void *arg, int iters)