356 {
357 int i;
360 unsigned char rand32[32];
362
363
364
365
366 setbuf(stdout, NULL);
367
368
369 setbuf(stderr, NULL);
370
372
373
374 if (argc > 1) {
376 }
377 printf(
"test count = %i\n", count);
378
379
380 secp256k1_testrand_init(argc > 2 ?
argv[2] : NULL);
381
382
383 if (argc > 4) {
384 num_cores = strtol(
argv[3], NULL, 0);
385 this_core = strtol(
argv[4], NULL, 0);
386 if (num_cores < 1 || this_core >= num_cores) {
387 fprintf(stderr,
"Usage: %s [count] [seed] [numcores] [thiscore]\n",
argv[0]);
388 return 1;
389 }
390 printf(
"running tests for core %lu (out of [0..%lu])\n", (
unsigned long)this_core, (
unsigned long)num_cores - 1);
391 }
392
393
396
397 while (count--) {
398
400 secp256k1_testrand256(rand32);
402
403
404 secp256k1_gej_set_infinity(&groupj[0]);
405 secp256k1_ge_set_gej(&group[0], &groupj[0]);
407 secp256k1_gej_add_ge(&groupj[i], &groupj[i - 1], &secp256k1_ge_const_g);
408 secp256k1_ge_set_gej(&group[i], &groupj[i]);
409 if (count != 0) {
410
411
414 secp256k1_gej_rescale(&groupj[i], &z);
415 }
416
417
418 {
422
423 secp256k1_scalar_set_int(&scalar_i, i);
424 secp256k1_ecmult_gen(&ctx->
ecmult_gen_ctx, &generatedj, &scalar_i);
425 secp256k1_ge_set_gej(&generated, &generatedj);
426
427 CHECK(group[i].infinity == 0);
429 CHECK(secp256k1_fe_equal_var(&generated.
x, &group[i].x));
430 CHECK(secp256k1_fe_equal_var(&generated.
y, &group[i].y));
431 }
432 }
433
434
441
442#ifdef ENABLE_MODULE_RECOVERY
443 test_exhaustive_recovery(ctx, group);
444#endif
445#ifdef ENABLE_MODULE_EXTRAKEYS
446 test_exhaustive_extrakeys(ctx, group);
447#endif
448#ifdef ENABLE_MODULE_SCHNORRSIG
449 test_exhaustive_schnorrsig(ctx);
450#endif
451
453 }
454
455 secp256k1_testrand_finish();
456
457 printf(
"no problems found\n");
458 return 0;
459}
#define ECMULT_GEN_PREC_BITS
LOGGING_API void printf(Category category, const char *format,...)
const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)]
const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)]
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)]
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
#define SECP256K1_CONTEXT_VERIFY
secp256k1_ecmult_gen_context ecmult_gen_ctx
void test_exhaustive_ecmult_multi(const secp256k1_context *ctx, const secp256k1_ge *group)
void test_exhaustive_ecmult(const secp256k1_ge *group, const secp256k1_gej *groupj)
void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *group)
void test_exhaustive_addition(const secp256k1_ge *group, const secp256k1_gej *groupj)
void test_exhaustive_verify(const secp256k1_context *ctx, const secp256k1_ge *group)
void test_exhaustive_endomorphism(const secp256k1_ge *group)
void random_fe(secp256k1_fe *x)
#define EXHAUSTIVE_TEST_ORDER