Skip to content

Commit 7c6b9df

Browse files
committed
SQUASH ME: Fix silent merge conflicts
1 parent 4a0ea61 commit 7c6b9df

File tree

8 files changed

+127
-126
lines changed

8 files changed

+127
-126
lines changed

src/modules/batch/main_impl.h

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ int secp256k1_batch_verify(const secp256k1_context *ctx, secp256k1_batch *batch)
190190

191191
if (batch->len > 0) {
192192
int strauss_ret = secp256k1_ecmult_strauss_batch_internal(&ctx->error_callback, batch->data, &resj, batch->scalars, batch->points, &batch->sc_g, batch->len);
193+
(void)strauss_ret;
193194
int mid_res = secp256k1_gej_is_infinity(&resj);
194195

195196
/* `_strauss_batch_internal` should not fail due to insufficient memory.

src/modules/batch/tests_impl.h

+24-23
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ void test_batch_sha256_tagged(void) {
3838
#define N_TWK_CHECKS 10
3939
#define N_TERMS (N_TWK_CHECKS + 2*N_SIGS)
4040
void test_batch_api(void) {
41+
secp256k1_batch *batch_none;
42+
secp256k1_batch *batch_sign;
43+
secp256k1_batch *batch_vrfy;
44+
secp256k1_batch *batch_both;
45+
secp256k1_batch *batch_sttc;
46+
unsigned char aux_rand16[32];
47+
int ecount;
4148

4249
#ifdef ENABLE_MODULE_EXTRAKEYS
4350
unsigned char sk[32];
@@ -62,39 +69,33 @@ void test_batch_api(void) {
6269
secp256k1_context *sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
6370
secp256k1_context *vrfy = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY);
6471
secp256k1_context *both = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
65-
secp256k1_context *sttc = secp256k1_context_clone(secp256k1_context_no_precomp);
66-
secp256k1_batch *batch_none;
67-
secp256k1_batch *batch_sign;
68-
secp256k1_batch *batch_vrfy;
69-
secp256k1_batch *batch_both;
70-
secp256k1_batch *batch_sttc;
71-
unsigned char aux_rand16[32];
72-
int ecount;
73-
74-
secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount);
75-
secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount);
76-
secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount);
77-
secp256k1_context_set_error_callback(both, counting_illegal_callback_fn, &ecount);
78-
secp256k1_context_set_error_callback(sttc, counting_illegal_callback_fn, &ecount);
79-
secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount);
80-
secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount);
81-
secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount);
82-
secp256k1_context_set_illegal_callback(both, counting_illegal_callback_fn, &ecount);
83-
secp256k1_context_set_illegal_callback(sttc, counting_illegal_callback_fn, &ecount);
72+
secp256k1_context *sttc = malloc(sizeof(*secp256k1_context_no_precomp));
73+
memcpy(sttc, secp256k1_context_no_precomp, sizeof(secp256k1_context));
74+
75+
secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount);
76+
secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount);
77+
secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount);
78+
secp256k1_context_set_error_callback(both, counting_callback_fn, &ecount);
79+
secp256k1_context_set_error_callback(sttc, counting_callback_fn, &ecount);
80+
secp256k1_context_set_illegal_callback(none, counting_callback_fn, &ecount);
81+
secp256k1_context_set_illegal_callback(sign, counting_callback_fn, &ecount);
82+
secp256k1_context_set_illegal_callback(vrfy, counting_callback_fn, &ecount);
83+
secp256k1_context_set_illegal_callback(both, counting_callback_fn, &ecount);
84+
secp256k1_context_set_illegal_callback(sttc, counting_callback_fn, &ecount);
8485

8586
/* 16 byte auxiliary randomness */
86-
secp256k1_testrand256(aux_rand16);
87+
testrand256(aux_rand16);
8788
memset(&aux_rand16[16], 0, 16);
8889

8990
#ifdef ENABLE_MODULE_EXTRAKEYS
9091
/* generate keypair data */
91-
secp256k1_testrand256(sk);
92+
testrand256(sk);
9293
CHECK(secp256k1_keypair_create(sign, &keypair, sk) == 1);
9394
CHECK(secp256k1_keypair_xonly_pub(sign, &pk, NULL, &keypair) == 1);
9495

9596
/* generate N_TWK_CHECKS tweak check data (tweaked_pk, tweaked_pk_parity, tweak) */
9697
for (i = 0; i < N_TWK_CHECKS; i++) {
97-
secp256k1_testrand256(tweak[i]);
98+
testrand256(tweak[i]);
9899
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &tmp_pk, &pk, tweak[i]));
99100
CHECK(secp256k1_xonly_pubkey_from_pubkey(vrfy, &tmp_xonly_pk, &tweaked_pk_parity[i], &tmp_pk));
100101
CHECK(secp256k1_xonly_pubkey_serialize(vrfy, tweaked_pk[i], &tmp_xonly_pk));
@@ -105,7 +106,7 @@ void test_batch_api(void) {
105106
#ifdef ENABLE_MODULE_SCHNORRSIG
106107
/* generate N_SIGS schnorr verify data (msg, sig) */
107108
for (i = 0; i < N_SIGS; i++) {
108-
secp256k1_testrand256(msg[i]);
109+
testrand256(msg[i]);
109110
CHECK(secp256k1_schnorrsig_sign32(sign, sig[i], msg[i], &keypair, NULL) == 1);
110111
CHECK(secp256k1_schnorrsig_verify(vrfy, sig[i], msg[i], sizeof(msg[i]), &pk));
111112
}

src/modules/extrakeys/batch_add_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int secp256k1_batch_add_xonlypub_tweak_check(const secp256k1_context* ctx, secp2
9595
return 0;
9696
}
9797

98-
if (!secp256k1_fe_set_b32(&qx, tweaked_pubkey32)) {
98+
if (!secp256k1_fe_set_b32_limit(&qx, tweaked_pubkey32)) {
9999
return 0;
100100
}
101101

src/modules/extrakeys/batch_add_tests_impl.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void batch_xonlypub_tweak_randomizer_gen_bitflip(secp256k1_sha256 *sha, unsigned
1212
secp256k1_sha256 sha_cpy;
1313
sha_cpy = *sha;
1414
secp256k1_batch_xonlypub_tweak_randomizer_gen(randomizers[0], &sha_cpy, args[0], args[1], args[2], args[3]);
15-
secp256k1_testrand_flip(args[n_flip], n_bytes);
15+
testrand_flip(args[n_flip], n_bytes);
1616
sha_cpy = *sha;
1717
secp256k1_batch_xonlypub_tweak_randomizer_gen(randomizers[1], &sha_cpy, args[0], args[1], args[2], args[3]);
1818
CHECK(secp256k1_memcmp_var(randomizers[0], randomizers[1], 32) != 0);
@@ -35,11 +35,11 @@ void run_batch_xonlypub_tweak_randomizer_gen_tests(void) {
3535
uint8_t temp_rand;
3636

3737
/* generate i-th tweak check data */
38-
secp256k1_testrand256(tweaked_pk);
39-
tweaked_pk_parity = (unsigned char) secp256k1_testrand_int(2);
40-
secp256k1_testrand256(tweak);
41-
secp256k1_testrand256(&internal_pk[1]);
42-
temp_rand = secp256k1_testrand_int(2) + 2; /* randomly choose 2 or 3 */
38+
testrand256(tweaked_pk);
39+
tweaked_pk_parity = (unsigned char) testrand_int(2);
40+
testrand256(tweak);
41+
testrand256(&internal_pk[1]);
42+
temp_rand = testrand_int(2) + 2; /* randomly choose 2 or 3 */
4343
internal_pk[0] = (unsigned char)temp_rand;
4444

4545
/* check bitflip in any argument results in generates randomizers */
@@ -48,7 +48,7 @@ void run_batch_xonlypub_tweak_randomizer_gen_tests(void) {
4848
args[2] = internal_pk;
4949
args[3] = tweak;
5050

51-
for (j = 0; j < count; j++) {
51+
for (j = 0; j < COUNT; j++) {
5252
batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 0, 32);
5353
batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 1, 1);
5454
batch_xonlypub_tweak_randomizer_gen_bitflip(&sha, args, 2, 33);
@@ -86,21 +86,21 @@ void test_batch_add_xonlypub_tweak_api(void) {
8686
secp256k1_batch *batch2 = secp256k1_batch_create(none, 1, NULL);
8787
int ecount;
8888

89-
secp256k1_context_set_error_callback(none, counting_illegal_callback_fn, &ecount);
90-
secp256k1_context_set_error_callback(sign, counting_illegal_callback_fn, &ecount);
91-
secp256k1_context_set_error_callback(vrfy, counting_illegal_callback_fn, &ecount);
92-
secp256k1_context_set_illegal_callback(none, counting_illegal_callback_fn, &ecount);
93-
secp256k1_context_set_illegal_callback(sign, counting_illegal_callback_fn, &ecount);
94-
secp256k1_context_set_illegal_callback(vrfy, counting_illegal_callback_fn, &ecount);
89+
secp256k1_context_set_error_callback(none, counting_callback_fn, &ecount);
90+
secp256k1_context_set_error_callback(sign, counting_callback_fn, &ecount);
91+
secp256k1_context_set_error_callback(vrfy, counting_callback_fn, &ecount);
92+
secp256k1_context_set_illegal_callback(none, counting_callback_fn, &ecount);
93+
secp256k1_context_set_illegal_callback(sign, counting_callback_fn, &ecount);
94+
secp256k1_context_set_illegal_callback(vrfy, counting_callback_fn, &ecount);
9595

9696
/** generate keypair data **/
97-
secp256k1_testrand256(sk);
97+
testrand256(sk);
9898
CHECK(secp256k1_keypair_create(sign, &keypair, sk) == 1);
9999
CHECK(secp256k1_keypair_xonly_pub(sign, &pk, NULL, &keypair) == 1);
100100
memset(overflows, 0xFF, sizeof(overflows));
101101

102102
/** generate tweak check data (tweaked_pk, tweaked_pk_parity, tweak) **/
103-
secp256k1_testrand256(tweak);
103+
testrand256(tweak);
104104
CHECK(secp256k1_xonly_pubkey_tweak_add(vrfy, &tmp_pk, &pk, tweak));
105105
CHECK(secp256k1_xonly_pubkey_from_pubkey(vrfy, &tmp_xonly_pk, &tweaked_pk_parity, &tmp_pk));
106106
CHECK(secp256k1_xonly_pubkey_serialize(vrfy, tweaked_pk, &tmp_xonly_pk));

src/modules/schnorrsig/batch_add_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int secp256k1_batch_add_schnorrsig(const secp256k1_context* ctx, secp256k1_batch
9494
return 0;
9595
}
9696

97-
if (!secp256k1_fe_set_b32(&rx, &sig64[0])) {
97+
if (!secp256k1_fe_set_b32_limit(&rx, &sig64[0])) {
9898
return 0;
9999
}
100100

0 commit comments

Comments
 (0)