From d6439f210138bc69a22b23bb8be1ca6049518fd5 Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Mon, 9 Oct 2023 20:13:24 +0200 Subject: [PATCH] WIP: Silent merge conflicts --- src/modules/batch/tests_impl.h | 39 ++++---- src/modules/extrakeys/batch_add_impl.h | 2 +- src/modules/extrakeys/batch_add_tests_impl.h | 14 +-- src/modules/schnorrsig/batch_add_impl.h | 2 +- src/modules/schnorrsig/batch_add_tests_impl.h | 94 +++++++++---------- src/modules/schnorrsig/tests_impl.h | 14 +-- src/tests.c | 17 ++-- 7 files changed, 89 insertions(+), 93 deletions(-) diff --git a/src/modules/batch/tests_impl.h b/src/modules/batch/tests_impl.h index 783747ae58..4bf3e64bcc 100644 --- a/src/modules/batch/tests_impl.h +++ b/src/modules/batch/tests_impl.h @@ -62,25 +62,22 @@ void test_batch_api(void) { secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); secp256k1_context *vrfy = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); secp256k1_context *both = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - secp256k1_context *sttc = secp256k1_context_clone(secp256k1_context_no_precomp); - secp256k1_batch *batch_none; - secp256k1_batch *batch_sign; - secp256k1_batch *batch_vrfy; - secp256k1_batch *batch_both; - secp256k1_batch *batch_sttc; + secp256k1_context *sttc = malloc(sizeof(*secp256k1_context_no_precomp)); + memcpy(sttc, secp256k1_context_no_precomp, sizeof(secp256k1_context)); + unsigned char aux_rand16[32]; int ecount; - secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(both, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(sttc, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(both, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(sttc, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(both, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(sttc, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(vrfy, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(both, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sttc, counting_callback_fn, &ecount); /* 16 byte auxiliary randomness */ testrand256(aux_rand16); @@ -114,21 +111,21 @@ void test_batch_api(void) { /** main test body **/ /* batch_create tests */ ecount = 0; - batch_none = secp256k1_batch_create(none, 1, NULL); + secp256k1_batch *batch_none = secp256k1_batch_create(none, 1, NULL); CHECK(batch_none != NULL); CHECK(ecount == 0); /* 2*N_SIGS since one schnorrsig creates two scalar-point pair in batch */ - batch_sign = secp256k1_batch_create(sign, 2*N_SIGS, NULL); + secp256k1_batch *batch_sign = secp256k1_batch_create(sign, 2*N_SIGS, NULL); CHECK(batch_sign != NULL); CHECK(ecount == 0); - batch_vrfy = secp256k1_batch_create(vrfy, N_TWK_CHECKS - 1, aux_rand16); + secp256k1_batch *batch_vrfy = secp256k1_batch_create(vrfy, N_TWK_CHECKS - 1, aux_rand16); CHECK(batch_vrfy != NULL); CHECK(ecount == 0); - batch_both = secp256k1_batch_create(both, N_TERMS/4, aux_rand16); + secp256k1_batch *batch_both = secp256k1_batch_create(both, N_TERMS/4, aux_rand16); CHECK(batch_both != NULL); CHECK(ecount == 0); /* ARG_CHECK(max_terms != 0) in `batch_create` should fail*/ - batch_sttc = secp256k1_batch_create(sttc, 0, NULL); + secp256k1_batch *batch_sttc = secp256k1_batch_create(sttc, 0, NULL); CHECK(batch_sttc == NULL); CHECK(ecount == 1); diff --git a/src/modules/extrakeys/batch_add_impl.h b/src/modules/extrakeys/batch_add_impl.h index cca6d5665b..3074214585 100644 --- a/src/modules/extrakeys/batch_add_impl.h +++ b/src/modules/extrakeys/batch_add_impl.h @@ -95,7 +95,7 @@ int secp256k1_batch_add_xonlypub_tweak_check(const secp256k1_context* ctx, secp2 return 0; } - if (!secp256k1_fe_set_b32(&qx, tweaked_pubkey32)) { + if (!secp256k1_fe_set_b32_limit(&qx, tweaked_pubkey32)) { return 0; } diff --git a/src/modules/extrakeys/batch_add_tests_impl.h b/src/modules/extrakeys/batch_add_tests_impl.h index 51d00ed1a4..d18aafcc1b 100644 --- a/src/modules/extrakeys/batch_add_tests_impl.h +++ b/src/modules/extrakeys/batch_add_tests_impl.h @@ -48,7 +48,7 @@ void run_batch_xonlypub_tweak_randomizer_gen_tests(void) { args[2] = internal_pk; args[3] = tweak; - for (j = 0; j < count; j++) { + for (j = 0; j < COUNT; j++) { batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 0, 32); batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 1, 1); batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 2, 33); @@ -86,12 +86,12 @@ void test_batch_add_xonlypub_tweak_api(void) { secp256k1_batch *batch2 = secp256k1_batch_create(none, 1, NULL); int ecount; - secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(vrfy, counting_callback_fn, &ecount); /** generate keypair data **/ testrand256(sk); diff --git a/src/modules/schnorrsig/batch_add_impl.h b/src/modules/schnorrsig/batch_add_impl.h index ae6aa03fc1..d43e6a34db 100644 --- a/src/modules/schnorrsig/batch_add_impl.h +++ b/src/modules/schnorrsig/batch_add_impl.h @@ -94,7 +94,7 @@ int secp256k1_batch_add_schnorrsig(const secp256k1_context* ctx, secp256k1_batch return 0; } - if (!secp256k1_fe_set_b32(&rx, &sig64[0])) { + if (!secp256k1_fe_set_b32_limit(&rx, &sig64[0])) { return 0; } diff --git a/src/modules/schnorrsig/batch_add_tests_impl.h b/src/modules/schnorrsig/batch_add_tests_impl.h index 3ee9cd4029..89c3122225 100644 --- a/src/modules/schnorrsig/batch_add_tests_impl.h +++ b/src/modules/schnorrsig/batch_add_tests_impl.h @@ -51,7 +51,7 @@ void run_batch_schnorrsig_randomizer_gen_tests(void) { args[1] = msg; args[2] = compressed_pk; - for (j = 0; j < count; j++) { + for (j = 0; j < COUNT; j++) { batch_schnorrsig_randomizer_gen_bitflip(&sha, args, 0, 64, msglen); batch_schnorrsig_randomizer_gen_bitflip(&sha, args, 1, 32, msglen); batch_schnorrsig_randomizer_gen_bitflip(&sha, args, 2, 33, msglen); @@ -61,7 +61,7 @@ void run_batch_schnorrsig_randomizer_gen_tests(void) { sha_cpy = sha; secp256k1_batch_schnorrsig_randomizer_gen(randomizer, &sha_cpy, sig, msg, msglen, compressed_pk); - for (j = 0; j < count; j++) { + for (j = 0; j < COUNT; j++) { unsigned char randomizer2[32]; uint32_t offset = testrand_int(msglen - 1); size_t msglen_tmp = (msglen + offset) % msglen; @@ -85,16 +85,16 @@ void run_batch_schnorrsig_randomizer_gen_tests(void) { void test_schnorrsig_sign_verify_check_batch(secp256k1_batch *batch, unsigned char *sig64, unsigned char *msg, size_t msglen, secp256k1_xonly_pubkey *pk) { int ret; - CHECK(secp256k1_batch_usable(ctx, batch)); + CHECK(secp256k1_batch_usable(CTX, batch)); /* filling a random byte (in msg or sig) can cause the following: * 1. unparsable msg or sig - here, batch_add_schnorrsig fails and batch_verify passes * 2. invalid schnorr eqn - here, batch_verify fails and batch_add_schnorrsig passes */ - ret = secp256k1_batch_add_schnorrsig(ctx, batch, sig64, msg, msglen, pk); + ret = secp256k1_batch_add_schnorrsig(CTX, batch, sig64, msg, msglen, pk); if (ret == 0) { - CHECK(secp256k1_batch_verify(ctx, batch) == 1); + CHECK(secp256k1_batch_verify(CTX, batch) == 1); } else if (ret == 1) { - CHECK(secp256k1_batch_verify(ctx, batch) == 0); + CHECK(secp256k1_batch_verify(CTX, batch) == 0); } } @@ -117,24 +117,24 @@ void test_schnorrsig_sign_batch_verify(void) { /* batch[0] will be used where batch_add and batch_verify * are expected to succed */ - batch[0] = secp256k1_batch_create(ctx, 2*N_SIGS, NULL); + batch[0] = secp256k1_batch_create(CTX, 2*N_SIGS, NULL); for (i = 0; i < N_SIGS; i++) { - batch[i+1] = secp256k1_batch_create(ctx, 2*ONE_SIG, NULL); + batch[i+1] = secp256k1_batch_create(CTX, 2*ONE_SIG, NULL); } - batch_fail1 = secp256k1_batch_create(ctx, 2*ONE_SIG, NULL); - batch_fail2 = secp256k1_batch_create(ctx, 2*ONE_SIG, NULL); + batch_fail1 = secp256k1_batch_create(CTX, 2*ONE_SIG, NULL); + batch_fail2 = secp256k1_batch_create(CTX, 2*ONE_SIG, NULL); testrand256(sk); - CHECK(secp256k1_keypair_create(ctx, &keypair, sk)); - CHECK(secp256k1_keypair_xonly_pub(ctx, &pk, NULL, &keypair)); + CHECK(secp256k1_keypair_create(CTX, &keypair, sk)); + CHECK(secp256k1_keypair_xonly_pub(CTX, &pk, NULL, &keypair)); for (i = 0; i < N_SIGS; i++) { testrand256(msg[i]); - CHECK(secp256k1_schnorrsig_sign32(ctx, sig[i], msg[i], &keypair, NULL)); - CHECK(secp256k1_batch_usable(ctx, batch[0])); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[i], msg[i], sizeof(msg[i]), &pk)); + CHECK(secp256k1_schnorrsig_sign32(CTX, sig[i], msg[i], &keypair, NULL)); + CHECK(secp256k1_batch_usable(CTX, batch[0])); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[i], msg[i], sizeof(msg[i]), &pk)); } - CHECK(secp256k1_batch_verify(ctx, batch[0])); + CHECK(secp256k1_batch_verify(CTX, batch[0])); { /* Flip a few bits in the signature and in the message and check that @@ -158,29 +158,29 @@ void test_schnorrsig_sign_batch_verify(void) { msg[sig_idx][byte_idx] ^= xorbyte; /* Check that above bitflips have been reversed correctly */ - CHECK(secp256k1_schnorrsig_verify(ctx, sig[sig_idx], msg[sig_idx], sizeof(msg[sig_idx]), &pk)); + CHECK(secp256k1_schnorrsig_verify(CTX, sig[sig_idx], msg[sig_idx], sizeof(msg[sig_idx]), &pk)); } /* Test overflowing s */ - CHECK(secp256k1_schnorrsig_sign32(ctx, sig[0], msg[0], &keypair, NULL)); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 1); + CHECK(secp256k1_schnorrsig_sign32(CTX, sig[0], msg[0], &keypair, NULL)); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 1); memset(&sig[0][32], 0xFF, 32); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 0); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 0); /* Test negative s */ - CHECK(secp256k1_schnorrsig_sign32(ctx, sig[0], msg[0], &keypair, NULL)); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 1); + CHECK(secp256k1_schnorrsig_sign32(CTX, sig[0], msg[0], &keypair, NULL)); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[0], msg[0], sizeof(msg[0]), &pk) == 1); secp256k1_scalar_set_b32(&s, &sig[0][32], NULL); secp256k1_scalar_negate(&s, &s); secp256k1_scalar_get_b32(&sig[0][32], &s); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch_fail1, sig[0], msg[0], sizeof(msg[0]), &pk) == 1); - CHECK(secp256k1_batch_verify(ctx, batch_fail1) == 0); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch_fail1, sig[0], msg[0], sizeof(msg[0]), &pk) == 1); + CHECK(secp256k1_batch_verify(CTX, batch_fail1) == 0); /* The empty message can be signed & verified */ - CHECK(secp256k1_schnorrsig_sign_custom(ctx, sig[0], NULL, 0, &keypair, NULL) == 1); - CHECK(secp256k1_batch_usable(ctx, batch[0]) == 1); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[0], NULL, 0, &pk) == 1); - CHECK(secp256k1_batch_verify(ctx, batch[0]) == 1); + CHECK(secp256k1_schnorrsig_sign_custom(CTX, sig[0], NULL, 0, &keypair, NULL) == 1); + CHECK(secp256k1_batch_usable(CTX, batch[0]) == 1); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[0], NULL, 0, &pk) == 1); + CHECK(secp256k1_batch_verify(CTX, batch[0]) == 1); { /* Test varying message lengths */ @@ -189,23 +189,23 @@ void test_schnorrsig_sign_batch_verify(void) { for (i = 0; i < sizeof(msg_large); i += 32) { testrand256(&msg_large[i]); } - CHECK(secp256k1_schnorrsig_sign_custom(ctx, sig[0], msg_large, msglen, &keypair, NULL) == 1); - CHECK(secp256k1_batch_usable(ctx, batch[0]) == 1); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch[0], sig[0], msg_large, msglen, &pk) == 1); - CHECK(secp256k1_batch_verify(ctx, batch[0]) == 1); + CHECK(secp256k1_schnorrsig_sign_custom(CTX, sig[0], msg_large, msglen, &keypair, NULL) == 1); + CHECK(secp256k1_batch_usable(CTX, batch[0]) == 1); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch[0], sig[0], msg_large, msglen, &pk) == 1); + CHECK(secp256k1_batch_verify(CTX, batch[0]) == 1); /* batch_add fails for a random wrong message length */ msglen = (msglen + (sizeof(msg_large) - 1)) % sizeof(msg_large); - CHECK(secp256k1_batch_usable(ctx, batch_fail2) == 1); - CHECK(secp256k1_batch_add_schnorrsig(ctx, batch_fail2, sig[0], msg_large, msglen, &pk) == 1); - CHECK(secp256k1_batch_verify(ctx, batch_fail2) == 0); + CHECK(secp256k1_batch_usable(CTX, batch_fail2) == 1); + CHECK(secp256k1_batch_add_schnorrsig(CTX, batch_fail2, sig[0], msg_large, msglen, &pk) == 1); + CHECK(secp256k1_batch_verify(CTX, batch_fail2) == 0); } /* Destroy the batch objects */ for (i = 0; i < N_SIGS+1; i++) { - secp256k1_batch_destroy(ctx, batch[i]); + secp256k1_batch_destroy(CTX, batch[i]); } - secp256k1_batch_destroy(ctx, batch_fail1); - secp256k1_batch_destroy(ctx, batch_fail2); + secp256k1_batch_destroy(CTX, batch_fail1); + secp256k1_batch_destroy(CTX, batch_fail2); } #undef N_SIGS /* ONE_SIG is undefined after `test_batch_add_schnorrsig_api` */ @@ -228,12 +228,12 @@ void test_batch_add_schnorrsig_api(void) { secp256k1_batch *batch2 = secp256k1_batch_create(none, 2*ONE_SIG, NULL); int ecount; - secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount); - secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount); + secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(none, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(sign, counting_callback_fn, &ecount); + secp256k1_context_set_illegal_callback(vrfy, counting_callback_fn, &ecount); /** generate keypair data **/ testrand256(sk); @@ -288,9 +288,9 @@ void test_batch_add_schnorrsig_api(void) { CHECK(ecount == 0); ecount = 0; - secp256k1_batch_destroy(ctx, batch1); + secp256k1_batch_destroy(CTX, batch1); CHECK(ecount == 0); - secp256k1_batch_destroy(ctx, batch2); + secp256k1_batch_destroy(CTX, batch2); CHECK(ecount == 0); secp256k1_context_destroy(none); @@ -304,7 +304,7 @@ void run_batch_add_schnorrsig_tests(void) { run_batch_schnorrsig_randomizer_gen_tests(); test_batch_add_schnorrsig_api(); - for (i = 0; i < count; i++) { + for (i = 0; i < COUNT; i++) { test_schnorrsig_sign_batch_verify(); } } diff --git a/src/modules/schnorrsig/tests_impl.h b/src/modules/schnorrsig/tests_impl.h index 0e808afdb9..0ffcc67bed 100644 --- a/src/modules/schnorrsig/tests_impl.h +++ b/src/modules/schnorrsig/tests_impl.h @@ -197,7 +197,7 @@ static void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, c } /* Helper function for schnorrsig_bip_vectors - * Checks that both verify and verify_batch (TODO) return the same value as expected. */ + * Checks that schnorrsig_verify returns the same value as expected. */ static void test_schnorrsig_bip_vectors_check_verify(const unsigned char *pk_serialized, const unsigned char *msg, size_t msglen, const unsigned char *sig, int expected) { secp256k1_xonly_pubkey pk; @@ -212,13 +212,13 @@ void test_schnorrsig_bip_vectors_check_batch_verify(const unsigned char *pk_seri secp256k1_xonly_pubkey pk; secp256k1_batch *batch; - CHECK(secp256k1_xonly_pubkey_parse(ctx, &pk, pk_serialized)); - batch = secp256k1_batch_create(ctx, 2, NULL); + CHECK(secp256k1_xonly_pubkey_parse(CTX, &pk, pk_serialized)); + batch = secp256k1_batch_create(CTX, 2, NULL); CHECK(batch != NULL); - CHECK(secp256k1_batch_usable(ctx, batch) == 1); - CHECK(add_expected == secp256k1_batch_add_schnorrsig(ctx, batch, sig, msg32, 32, &pk)); - CHECK(verify_expected == secp256k1_batch_verify(ctx, batch)); - secp256k1_batch_destroy(ctx, batch); + CHECK(secp256k1_batch_usable(CTX, batch) == 1); + CHECK(add_expected == secp256k1_batch_add_schnorrsig(CTX, batch, sig, msg32, 32, &pk)); + CHECK(verify_expected == secp256k1_batch_verify(CTX, batch)); + secp256k1_batch_destroy(CTX, batch); } #endif diff --git a/src/tests.c b/src/tests.c index ba08e378f7..e97b26b065 100644 --- a/src/tests.c +++ b/src/tests.c @@ -5045,19 +5045,19 @@ int test_ecmult_strauss_batch_internal_random(secp256k1_scratch *scratch) { int g_nonzero, num_nonzero; secp256k1_scalar *scratch_scalars; secp256k1_gej *scratch_points; - size_t checkpoint = secp256k1_scratch_checkpoint(&ctx->error_callback, scratch); + size_t checkpoint = secp256k1_scratch_checkpoint(&CTX->error_callback, scratch); int i; /* generate inputs and their ecmult_multi output */ ecmult_multi_random_generate_inp(&expected, g_scalar_ptr, scalars, gejs, &filled, &num_nonzero, &g_nonzero, &mults); /* allocate inputs on the scratch space */ - scratch_scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, filled*sizeof(secp256k1_scalar)); - scratch_points = (secp256k1_gej*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, filled*sizeof(secp256k1_gej)); + scratch_scalars = (secp256k1_scalar*)secp256k1_scratch_alloc(&CTX->error_callback, scratch, filled*sizeof(secp256k1_scalar)); + scratch_points = (secp256k1_gej*)secp256k1_scratch_alloc(&CTX->error_callback, scratch, filled*sizeof(secp256k1_gej)); /* If scalar or point allocation fails, restore scratch space to previous state */ if (scratch_scalars == NULL || scratch_points == NULL) { - secp256k1_scratch_apply_checkpoint(&ctx->error_callback, scratch, checkpoint); + secp256k1_scratch_apply_checkpoint(&CTX->error_callback, scratch, checkpoint); return 0; } @@ -5067,19 +5067,18 @@ int test_ecmult_strauss_batch_internal_random(secp256k1_scratch *scratch) { scratch_points[i] = gejs[i]; } - CHECK(secp256k1_ecmult_strauss_batch_internal(&ctx->error_callback, scratch, &computed, scratch_scalars, scratch_points, g_scalar_ptr, filled)); + CHECK(secp256k1_ecmult_strauss_batch_internal(&CTX->error_callback, scratch, &computed, scratch_scalars, scratch_points, g_scalar_ptr, filled)); mults += num_nonzero + g_nonzero; /* Compare with expected result. */ secp256k1_gej_neg(&computed, &computed); secp256k1_gej_add_var(&computed, &computed, &expected, NULL); CHECK(secp256k1_gej_is_infinity(&computed)); - secp256k1_scratch_apply_checkpoint(&ctx->error_callback, scratch, checkpoint); + secp256k1_scratch_apply_checkpoint(&CTX->error_callback, scratch, checkpoint); return mults; } void test_ecmult_multi_batch_single(secp256k1_ecmult_multi_func ecmult_multi) { - secp256k1_scalar szero; secp256k1_scalar sc; secp256k1_ge pt; secp256k1_gej r; @@ -5265,9 +5264,9 @@ static void test_ecmult_multi_batching(void) { static void run_ecmult_multi_tests(void) { secp256k1_scratch *scratch; - int64_t todo_multi = (int64_t)320 * count; + int64_t todo_multi = (int64_t)320 * COUNT; /* todo: what should be the intial val of `todo_strauss_internal` */ - int64_t todo_strauss_internal = (int64_t)320 * count; + int64_t todo_strauss_internal = (int64_t)320 * COUNT; test_secp256k1_pippenger_bucket_window_inv(); test_ecmult_multi_pippenger_max_points();