Skip to content

Commit 5a40f3d

Browse files
committed
replace memcmp with secp256k1_memcmp_var throughout the codebase
memcmp only appears in -zkp-specific modules. Fix those.
1 parent 92820d9 commit 5a40f3d

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

src/modules/ecdsa_s2c/tests_impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void run_s2c_opening_test(void) {
7878
* points' x-coordinates are uniformly random */
7979
if (secp256k1_ecdsa_s2c_opening_parse(none, &opening, input) == 1) {
8080
CHECK(secp256k1_ecdsa_s2c_opening_serialize(none, output, &opening) == 1);
81-
CHECK(memcmp(output, input, sizeof(output)) == 0);
81+
CHECK(secp256k1_memcmp_var(output, input, sizeof(output)) == 0);
8282
}
8383
secp256k1_testrand256(&input[1]);
8484
/* Set pubkey oddness tag to first bit of input[1] */
@@ -255,7 +255,7 @@ static void test_ecdsa_s2c_fixed_vectors(void) {
255255
secp256k1_ecdsa_signature signature;
256256
CHECK(secp256k1_ecdsa_s2c_sign(ctx, &signature, &s2c_opening, message, privkey, test->s2c_data) == 1);
257257
CHECK(secp256k1_ecdsa_s2c_opening_serialize(ctx, opening_ser, &s2c_opening) == 1);
258-
CHECK(memcmp(test->expected_s2c_opening, opening_ser, sizeof(opening_ser)) == 0);
258+
CHECK(secp256k1_memcmp_var(test->expected_s2c_opening, opening_ser, sizeof(opening_ser)) == 0);
259259
CHECK(secp256k1_ecdsa_s2c_verify_commit(ctx, &signature, test->s2c_data, &s2c_opening) == 1);
260260
}
261261
}
@@ -331,7 +331,7 @@ static void test_ecdsa_anti_exfil_signer_commit(void) {
331331
const ecdsa_s2c_test *test = &ecdsa_s2c_tests[i];
332332
CHECK(secp256k1_ecdsa_anti_exfil_signer_commit(ctx, &s2c_opening, message, privkey, test->s2c_data) == 1);
333333
CHECK(secp256k1_ecdsa_s2c_opening_serialize(ctx, buf, &s2c_opening) == 1);
334-
CHECK(memcmp(test->expected_s2c_exfil_opening, buf, sizeof(buf)) == 0);
334+
CHECK(secp256k1_memcmp_var(test->expected_s2c_exfil_opening, buf, sizeof(buf)) == 0);
335335
}
336336
}
337337

@@ -397,7 +397,7 @@ static void test_ecdsa_anti_exfil(void) {
397397
CHECK(secp256k1_ecdsa_verify(ctx, &signature, host_msg, &signer_pubkey) == 1);
398398
CHECK(secp256k1_anti_exfil_host_verify(ctx, &signature, host_msg, &signer_pubkey, host_nonce_contribution, &s2c_opening) == 0);
399399
CHECK(secp256k1_anti_exfil_host_verify(ctx, &signature, host_msg, &signer_pubkey, bad_nonce_contribution, &s2c_opening) == 1);
400-
CHECK(memcmp(&s2c_opening, &orig_opening, sizeof(s2c_opening)) != 0);
400+
CHECK(secp256k1_memcmp_var(&s2c_opening, &orig_opening, sizeof(s2c_opening)) != 0);
401401
}
402402
}
403403

src/modules/generator/tests_impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void test_shallue_van_de_woestijne(void) {
134134
shallue_van_de_woestijne(&ge, &fe);
135135
secp256k1_ge_to_storage(&ges, &ge);
136136

137-
CHECK(memcmp(&ges, &results[i * 2 + s - 2], sizeof(secp256k1_ge_storage)) == 0);
137+
CHECK(secp256k1_memcmp_var(&ges, &results[i * 2 + s - 2], sizeof(secp256k1_ge_storage)) == 0);
138138
}
139139
}
140140
}
@@ -188,11 +188,11 @@ void test_generator_generate(void) {
188188
CHECK(secp256k1_generator_generate_blinded(ctx, &gen, v, s));
189189
secp256k1_generator_load(&ge, &gen);
190190
secp256k1_ge_to_storage(&ges, &ge);
191-
CHECK(memcmp(&ges, &results[i - 1], sizeof(secp256k1_ge_storage)) == 0);
191+
CHECK(secp256k1_memcmp_var(&ges, &results[i - 1], sizeof(secp256k1_ge_storage)) == 0);
192192
CHECK(secp256k1_generator_generate(ctx, &gen, v));
193193
secp256k1_generator_load(&ge, &gen);
194194
secp256k1_ge_to_storage(&ges, &ge);
195-
CHECK(memcmp(&ges, &results[i - 1], sizeof(secp256k1_ge_storage)) == 0);
195+
CHECK(secp256k1_memcmp_var(&ges, &results[i - 1], sizeof(secp256k1_ge_storage)) == 0);
196196
}
197197

198198
/* There is no range restriction on the value, but the blinder must be a
@@ -215,7 +215,7 @@ void test_generator_fixed_vector(void) {
215215

216216
CHECK(secp256k1_generator_parse(ctx, &parse, two_g));
217217
CHECK(secp256k1_generator_serialize(ctx, result, &parse));
218-
CHECK(memcmp(two_g, result, 33) == 0);
218+
CHECK(secp256k1_memcmp_var(two_g, result, 33) == 0);
219219

220220
result[0] = 0x0a;
221221
CHECK(secp256k1_generator_parse(ctx, &parse, result));

src/modules/musig/tests_impl.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
360360
secp256k1_musig_pubnonce tmp;
361361
CHECK(secp256k1_musig_pubnonce_serialize(none, pubnonce_ser, &pubnonce[0]) == 1);
362362
CHECK(secp256k1_musig_pubnonce_parse(none, &tmp, pubnonce_ser) == 1);
363-
CHECK(memcmp(&tmp, &pubnonce[0], sizeof(tmp)) == 0);
363+
CHECK(secp256k1_memcmp_var(&tmp, &pubnonce[0], sizeof(tmp)) == 0);
364364
}
365365

366366
/** Receive nonces and aggregate **/
@@ -414,7 +414,7 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
414414
secp256k1_musig_aggnonce tmp;
415415
CHECK(secp256k1_musig_aggnonce_serialize(none, aggnonce_ser, &aggnonce) == 1);
416416
CHECK(secp256k1_musig_aggnonce_parse(none, &tmp, aggnonce_ser) == 1);
417-
CHECK(memcmp(&tmp, &aggnonce, sizeof(tmp)) == 0);
417+
CHECK(secp256k1_memcmp_var(&tmp, &aggnonce, sizeof(tmp)) == 0);
418418
}
419419

420420
/** Process nonces **/
@@ -444,7 +444,7 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
444444
memcpy(&secnonce_tmp, &secnonce[0], sizeof(secnonce_tmp));
445445
CHECK(secp256k1_musig_partial_sign(none, &partial_sig[0], &secnonce_tmp, &keypair[0], &keyagg_cache, &session) == 1);
446446
/* The secnonce is set to 0 and subsequent signing attempts fail */
447-
CHECK(memcmp(&secnonce_tmp, zeros68, sizeof(secnonce_tmp)) == 0);
447+
CHECK(secp256k1_memcmp_var(&secnonce_tmp, zeros68, sizeof(secnonce_tmp)) == 0);
448448
CHECK(secp256k1_musig_partial_sign(none, &partial_sig[0], &secnonce_tmp, &keypair[0], &keyagg_cache, &session) == 0);
449449
CHECK(ecount == 1);
450450
memcpy(&secnonce_tmp, &secnonce[0], sizeof(secnonce_tmp));
@@ -496,7 +496,7 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
496496
secp256k1_musig_partial_sig tmp;
497497
CHECK(secp256k1_musig_partial_sig_serialize(none, buf, &partial_sig[0]) == 1);
498498
CHECK(secp256k1_musig_partial_sig_parse(none, &tmp, buf) == 1);
499-
CHECK(memcmp(&tmp, &partial_sig[0], sizeof(tmp)) == 0);
499+
CHECK(secp256k1_memcmp_var(&tmp, &partial_sig[0], sizeof(tmp)) == 0);
500500
}
501501

502502
/** Partial signature verification */
@@ -582,10 +582,10 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
582582
/** Secret adaptor can be extracted from signature */
583583
ecount = 0;
584584
CHECK(secp256k1_musig_extract_adaptor(none, sec_adaptor1, final_sig, pre_sig, nonce_parity) == 1);
585-
CHECK(memcmp(sec_adaptor, sec_adaptor1, 32) == 0);
585+
CHECK(secp256k1_memcmp_var(sec_adaptor, sec_adaptor1, 32) == 0);
586586
/* wrong nonce parity */
587587
CHECK(secp256k1_musig_extract_adaptor(none, sec_adaptor1, final_sig, pre_sig, !nonce_parity) == 1);
588-
CHECK(memcmp(sec_adaptor, sec_adaptor1, 32) != 0);
588+
CHECK(secp256k1_memcmp_var(sec_adaptor, sec_adaptor1, 32) != 0);
589589
CHECK(secp256k1_musig_extract_adaptor(none, NULL, final_sig, pre_sig, 0) == 0);
590590
CHECK(ecount == 1);
591591
CHECK(secp256k1_musig_extract_adaptor(none, sec_adaptor1, NULL, pre_sig, 0) == 0);
@@ -764,7 +764,7 @@ void scriptless_atomic_swap(secp256k1_scratch_space *scratch) {
764764
CHECK(secp256k1_musig_partial_sign(ctx, &partial_sig_a[1], &secnonce_a[1], &keypair_a[1], &keyagg_cache_a, &session_a) == 1);
765765
CHECK(secp256k1_musig_partial_sig_agg(ctx, pre_sig_a, &session_a, partial_sig_a_ptr, 2) == 1);
766766
CHECK(secp256k1_musig_extract_adaptor(ctx, sec_adaptor_extracted, final_sig_b, pre_sig_b, nonce_parity_b) == 1);
767-
CHECK(memcmp(sec_adaptor_extracted, sec_adaptor, sizeof(sec_adaptor)) == 0); /* in real life we couldn't check this, of course */
767+
CHECK(secp256k1_memcmp_var(sec_adaptor_extracted, sec_adaptor, sizeof(sec_adaptor)) == 0); /* in real life we couldn't check this, of course */
768768
CHECK(secp256k1_musig_adapt(ctx, final_sig_a, pre_sig_a, sec_adaptor_extracted, nonce_parity_a) == 1);
769769
CHECK(secp256k1_schnorrsig_verify(ctx, final_sig_a, msg32_a, sizeof(msg32_a), &agg_pk_a) == 1);
770770
}
@@ -794,7 +794,7 @@ void sha256_tag_test_internal(secp256k1_sha256 *sha_tagged, unsigned char *tag,
794794
secp256k1_sha256_write(sha_tagged, buf, 32);
795795
secp256k1_sha256_finalize(&sha, buf);
796796
secp256k1_sha256_finalize(sha_tagged, buf2);
797-
CHECK(memcmp(buf, buf2, 32) == 0);
797+
CHECK(secp256k1_memcmp_var(buf, buf2, 32) == 0);
798798
}
799799

800800
/* Checks that the initialized tagged hashes initialized have the expected
@@ -904,7 +904,7 @@ void musig_tweak_test(secp256k1_scratch_space *scratch) {
904904
} else {
905905
secp256k1_pubkey tmp_key = P[i-1];
906906
CHECK(secp256k1_ec_pubkey_tweak_add(ctx, &tmp_key, tweak));
907-
CHECK(memcmp(&tmp_key, &P[i], sizeof(tmp_key)) == 0);
907+
CHECK(secp256k1_memcmp_var(&tmp_key, &P[i], sizeof(tmp_key)) == 0);
908908
}
909909
/* Test signing for P[i] */
910910
musig_tweak_test_helper(&P_xonly[i], sk[0], sk[1], &keyagg_cache);
@@ -1138,7 +1138,7 @@ void musig_test_vectors_noncegen(void) {
11381138
for (j = 0; j < 2; j++) {
11391139
unsigned char k32[32];
11401140
secp256k1_scalar_get_b32(k32, &k[i][j]);
1141-
CHECK(memcmp(k32, k32_expected[i][j], 32) == 0);
1141+
CHECK(secp256k1_memcmp_var(k32, k32_expected[i][j], 32) == 0);
11421142
}
11431143
}
11441144
}
@@ -1264,7 +1264,7 @@ void musig_test_vectors_sign(void) {
12641264
CHECK(musig_test_pk_parity(&keyagg_cache) == 1);
12651265
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
12661266
CHECK(fin_nonce_parity == 1);
1267-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1267+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
12681268
}
12691269
{
12701270
/* This is a test where the aggregate public key point has an _even_ y
@@ -1281,7 +1281,7 @@ void musig_test_vectors_sign(void) {
12811281
CHECK(musig_test_pk_parity(&keyagg_cache) == 0);
12821282
CHECK(musig_test_is_second_pk(&keyagg_cache, sk));
12831283
CHECK(fin_nonce_parity == 0);
1284-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1284+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
12851285
}
12861286
{
12871287
/* This is a test where the parity of aggregate public key point (1) is unequal to the
@@ -1297,7 +1297,7 @@ void musig_test_vectors_sign(void) {
12971297
CHECK(musig_test_pk_parity(&keyagg_cache) == 1);
12981298
CHECK(fin_nonce_parity == 0);
12991299
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
1300-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1300+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
13011301
}
13021302
{
13031303
/* This is a test that includes an xonly public key tweak. */
@@ -1319,7 +1319,7 @@ void musig_test_vectors_sign(void) {
13191319
CHECK(musig_test_pk_parity(&keyagg_cache) == 1);
13201320
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
13211321
CHECK(fin_nonce_parity == 1);
1322-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1322+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
13231323
}
13241324
{
13251325
/* This is a test that includes an ordinary public key tweak. */
@@ -1341,7 +1341,7 @@ void musig_test_vectors_sign(void) {
13411341
CHECK(musig_test_pk_parity(&keyagg_cache) == 1);
13421342
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
13431343
CHECK(fin_nonce_parity == 0);
1344-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1344+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
13451345
}
13461346
{
13471347
/* This is a test that includes an ordinary and an x-only public key tweak. */
@@ -1371,7 +1371,7 @@ void musig_test_vectors_sign(void) {
13711371
CHECK(musig_test_pk_parity(&keyagg_cache) == 0);
13721372
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
13731373
CHECK(fin_nonce_parity == 0);
1374-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1374+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
13751375
}
13761376
{
13771377
/* This is a test with four tweaks: x-only, ordinary, x-only, ordinary. */
@@ -1412,7 +1412,7 @@ void musig_test_vectors_sign(void) {
14121412
CHECK(musig_test_pk_parity(&keyagg_cache) == 0);
14131413
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
14141414
CHECK(fin_nonce_parity == 1);
1415-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1415+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
14161416
}
14171417
{
14181418
/* This is a test that includes an adaptor. */
@@ -1435,7 +1435,7 @@ void musig_test_vectors_sign(void) {
14351435
CHECK(musig_test_pk_parity(&keyagg_cache) == 1);
14361436
CHECK(!musig_test_is_second_pk(&keyagg_cache, sk));
14371437
CHECK(fin_nonce_parity == 1);
1438-
CHECK(memcmp(sig, sig_expected, 32) == 0);
1438+
CHECK(secp256k1_memcmp_var(sig, sig_expected, 32) == 0);
14391439
}
14401440
}
14411441

src/modules/rangeproof/borromean_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int secp256k1_borromean_verify(secp256k1_scalar *evalues, const unsigned char *e
105105
}
106106
secp256k1_sha256_write(&sha256_e0, m, mlen);
107107
secp256k1_sha256_finalize(&sha256_e0, tmp);
108-
return memcmp(e0, tmp, 32) == 0;
108+
return secp256k1_memcmp_var(e0, tmp, 32) == 0;
109109
}
110110

111111
int secp256k1_borromean_sign(const secp256k1_ecmult_gen_context *ecmult_gen_ctx,

src/modules/rangeproof/rangeproof_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ SECP256K1_INLINE static int secp256k1_rangeproof_rewind_inner(secp256k1_scalar *
401401
idx = npub + rsizes[rings - 1] - 1 - j;
402402
secp256k1_scalar_get_b32(tmp, &s[idx]);
403403
secp256k1_rangeproof_ch32xor(tmp, &prep[idx * 32]);
404-
if ((tmp[0] & 128) && (memcmp(&tmp[16], &tmp[24], 8) == 0) && (memcmp(&tmp[8], &tmp[16], 8) == 0)) {
404+
if ((tmp[0] & 128) && (secp256k1_memcmp_var(&tmp[16], &tmp[24], 8) == 0) && (secp256k1_memcmp_var(&tmp[8], &tmp[16], 8) == 0)) {
405405
value = 0;
406406
for (i = 0; i < 8; i++) {
407407
value = (value << 8) + tmp[24 + i];

src/modules/rangeproof/tests_impl.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void test_rangeproof_api(const secp256k1_context *none, const secp256k1_c
196196
CHECK(max_value >= val);
197197
CHECK(value_out == val);
198198
CHECK(message_len == sizeof(message_out));
199-
CHECK(memcmp(message, message_out, sizeof(message_out)) == 0);
199+
CHECK(secp256k1_memcmp_var(message, message_out, sizeof(message_out)) == 0);
200200

201201
CHECK(secp256k1_rangeproof_rewind(both, NULL, &value_out, message_out, &message_len, commit.data, &min_value, &max_value, &commit, proof, len, ext_commit, ext_commit_len, secp256k1_generator_h) != 0);
202202
CHECK(*ecount == 21); /* blindout may be NULL */
@@ -434,21 +434,21 @@ static void test_rangeproof(void) {
434434
mlen = 4096;
435435
CHECK(secp256k1_rangeproof_rewind(ctx, blindout, &vout, message, &mlen, commit.data, &minv, &maxv, &commit, proof, len, NULL, 0, secp256k1_generator_h));
436436
if (input_message != NULL) {
437-
CHECK(memcmp(message, input_message, input_message_len) == 0);
437+
CHECK(secp256k1_memcmp_var(message, input_message, input_message_len) == 0);
438438
}
439439
for (j = input_message_len; j < mlen; j++) {
440440
CHECK(message[j] == 0);
441441
}
442442
CHECK(mlen <= 4096);
443-
CHECK(memcmp(blindout, blind, 32) == 0);
443+
CHECK(secp256k1_memcmp_var(blindout, blind, 32) == 0);
444444
CHECK(vout == v);
445445
CHECK(minv <= v);
446446
CHECK(maxv >= v);
447447
len = 5134;
448448
CHECK(secp256k1_rangeproof_sign(ctx, proof, &len, v, &commit, blind, commit.data, -1, 64, v, NULL, 0, NULL, 0, secp256k1_generator_h));
449449
CHECK(len <= 73);
450450
CHECK(secp256k1_rangeproof_rewind(ctx, blindout, &vout, NULL, NULL, commit.data, &minv, &maxv, &commit, proof, len, NULL, 0, secp256k1_generator_h));
451-
CHECK(memcmp(blindout, blind, 32) == 0);
451+
CHECK(secp256k1_memcmp_var(blindout, blind, 32) == 0);
452452
CHECK(vout == v);
453453
CHECK(minv == v);
454454
CHECK(maxv == v);
@@ -460,7 +460,7 @@ static void test_rangeproof(void) {
460460
CHECK(!secp256k1_rangeproof_rewind(ctx, blindout, &vout, NULL, NULL, commit.data, &minv, &maxv, &commit, proof, len, NULL, 0, secp256k1_generator_h));
461461
CHECK(!secp256k1_rangeproof_rewind(ctx, blindout, &vout, NULL, NULL, commit.data, &minv, &maxv, &commit, proof, len, message_long, sizeof(message_long), secp256k1_generator_h));
462462
CHECK(secp256k1_rangeproof_rewind(ctx, blindout, &vout, NULL, NULL, commit.data, &minv, &maxv, &commit, proof, len, message_short, sizeof(message_short), secp256k1_generator_h));
463-
CHECK(memcmp(blindout, blind, 32) == 0);
463+
CHECK(secp256k1_memcmp_var(blindout, blind, 32) == 0);
464464
CHECK(vout == v);
465465
CHECK(minv == v);
466466
CHECK(maxv == v);
@@ -527,7 +527,7 @@ static void test_rangeproof(void) {
527527
CHECK(message[j] == 0);
528528
}
529529
CHECK(mlen <= 4096);
530-
CHECK(memcmp(blindout, blind, 32) == 0);
530+
CHECK(secp256k1_memcmp_var(blindout, blind, 32) == 0);
531531

532532
CHECK(minv <= v);
533533
CHECK(maxv >= v);
@@ -591,8 +591,8 @@ static void test_rangeproof_null_blinder(void) {
591591
secp256k1_testrand256(&msg[96]);
592592
CHECK(secp256k1_rangeproof_sign(ctx, proof, &len, v, &commit, blind, commit.data, 0, 3, v, msg, sizeof(msg), NULL, 0, secp256k1_generator_h));
593593
CHECK(secp256k1_rangeproof_rewind(ctx, blind_out, &value_out, msg_out, &msg_len, commit.data, &minv, &maxv, &commit, proof, len, NULL, 0, secp256k1_generator_h) != 0);
594-
CHECK(memcmp(blind, blind_out, sizeof(blind)) == 0);
595-
CHECK(memcmp(msg, msg_out, sizeof(msg)) == 0);
594+
CHECK(secp256k1_memcmp_var(blind, blind_out, sizeof(blind)) == 0);
595+
CHECK(secp256k1_memcmp_var(msg, msg_out, sizeof(msg)) == 0);
596596
CHECK(value_out == v);
597597
CHECK(minv == v);
598598
CHECK(maxv == v + 7);
@@ -737,7 +737,7 @@ void test_pedersen_commitment_fixed_vector(void) {
737737

738738
CHECK(secp256k1_pedersen_commitment_parse(ctx, &parse, two_g));
739739
CHECK(secp256k1_pedersen_commitment_serialize(ctx, result, &parse));
740-
CHECK(memcmp(two_g, result, 33) == 0);
740+
CHECK(secp256k1_memcmp_var(two_g, result, 33) == 0);
741741

742742
result[0] = 0x08;
743743
CHECK(secp256k1_pedersen_commitment_parse(ctx, &parse, result));

src/modules/surjection/main_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ int secp256k1_surjectionproof_initialize(const secp256k1_context* ctx, secp256k1
243243
while (1) {
244244
size_t next_input_index;
245245
next_input_index = secp256k1_surjectionproof_csprng_next(&csprng, n_input_tags);
246-
if (memcmp(&fixed_input_tags[next_input_index], fixed_output_tag, sizeof(*fixed_output_tag)) == 0) {
246+
if (secp256k1_memcmp_var(&fixed_input_tags[next_input_index], fixed_output_tag, sizeof(*fixed_output_tag)) == 0) {
247247
*input_index = next_input_index;
248248
has_output_tag = 1;
249249
}

0 commit comments

Comments
 (0)