Skip to content

Commit 7226cf2

Browse files
committed
ecdsa_adaptor: fix too small buffer in tests
Also add a specific test that fails adaptor sig deserialization because with the correct size buffer that's not guaranteed anymore with the existing test.
1 parent b053e85 commit 7226cf2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/modules/ecdsa_adaptor/tests_impl.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,15 @@ void adaptor_tests(void) {
10321032
CHECK(secp256k1_ecdsa_adaptor_verify(ctx, adaptor_sig, &enckey, msg, &enckey) == 0);
10331033
CHECK(secp256k1_ecdsa_adaptor_verify(ctx, adaptor_sig, &pubkey, msg, &pubkey) == 0);
10341034
{
1035-
unsigned char adaptor_sig_tmp[65];
1035+
/* Test failed adaptor sig deserialization */
1036+
unsigned char adaptor_sig_tmp[162];
1037+
memset(&adaptor_sig_tmp, 0xFF, 162);
1038+
CHECK(secp256k1_ecdsa_adaptor_verify(ctx, adaptor_sig_tmp, &pubkey, msg, &enckey) == 0);
1039+
}
1040+
{
1041+
/* Test that any flipped bit in the adaptor signature will make
1042+
* verification fail */
1043+
unsigned char adaptor_sig_tmp[162];
10361044
memcpy(adaptor_sig_tmp, adaptor_sig, sizeof(adaptor_sig_tmp));
10371045
rand_flip_bit(&adaptor_sig_tmp[1], sizeof(adaptor_sig_tmp) - 1);
10381046
CHECK(secp256k1_ecdsa_adaptor_verify(ctx, adaptor_sig_tmp, &pubkey, msg, &enckey) == 0);

0 commit comments

Comments
 (0)