281 {
284 size_t scratch_size;
285
287
288 data.ecmult_multi = secp256k1_ecmult_multi_var;
289
290 if (argc > 1) {
295 return 0;
297 printf(
"Using pippenger_wnaf:\n");
298 data.ecmult_multi = secp256k1_ecmult_pippenger_batch_single;
300 printf(
"Using strauss_wnaf:\n");
301 data.ecmult_multi = secp256k1_ecmult_strauss_batch_single;
303 printf(
"Using simple algorithm:\n");
304 } else {
305 fprintf(stderr,
"%s: unrecognized argument '%s'.\n\n",
argv[0],
argv[1]);
307 return 1;
308 }
309 }
310
315 } else {
316 data.scratch = NULL;
317 }
318
319
324 data.expected_output = malloc(
sizeof(
secp256k1_gej) * (iters + 1));
326
327
328 secp256k1_gej_set_ge(&data.pubkeys_gej[0], &secp256k1_ge_const_g);
329 secp256k1_scalar_set_int(&data.seckeys[0], 1);
330 for (i = 0; i <
POINTS; ++i) {
331 generate_scalar(i, &data.scalars[i]);
332 if (i) {
333 secp256k1_gej_double_var(&data.pubkeys_gej[i], &data.pubkeys_gej[i - 1], NULL);
334 secp256k1_scalar_add(&data.seckeys[i], &data.seckeys[i - 1], &data.seckeys[i - 1]);
335 }
336 }
337 secp256k1_ge_set_all_gej_var(data.pubkeys, data.pubkeys_gej,
POINTS);
338
339
341
342 hash_into_offset(&data, 0);
343 run_ecmult_bench(&data, iters);
344
345 for (i = 1; i <= 8; ++i) {
346 run_ecmult_multi_bench(&data, i, 1, iters);
347 }
348
349
350
351
352 if (iters > 2) {
353 for (
p = 0;
p <= 11; ++
p) {
354 for (i = 9; i <= 16; ++i) {
355 run_ecmult_multi_bench(&data, i <<
p, 1, iters);
356 }
357 }
358 }
359
360 if (data.scratch != NULL) {
362 }
364 free(data.scalars);
365 free(data.pubkeys);
366 free(data.pubkeys_gej);
367 free(data.seckeys);
368 free(data.output);
369 free(data.expected_output);
370
371 return(0);
372}
void print_output_table_header_row(void)
int have_flag(int argc, char **argv, char *flag)
int get_iters(int default_iters)
#define STRAUSS_SCRATCH_OBJECTS
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT secp256k1_scratch_space * secp256k1_scratch_space_create(const secp256k1_context *ctx, size_t size) SECP256K1_ARG_NONNULL(1)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
SECP256K1_API void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space *scratch) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_VERIFY