Skip to content

Commit 5764b2b

Browse files
committed
f test that pubkey is zeroed after xonly_pubkey_parse returned 0
1 parent e28b61c commit 5764b2b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/tests.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,7 +4270,8 @@ void run_eckey_edge_case_test(void) {
42704270

42714271
void test_xonly_pubkey(void) {
42724272
unsigned char sk[32] = { 0 };
4273-
unsigned char garbage[32];
4273+
unsigned char ones32[32];
4274+
unsigned char zeros64[64] = { 0 };
42744275
secp256k1_pubkey xy_pk;
42754276
secp256k1_pubkey xy_pk_tmp;
42764277
secp256k1_xonly_pubkey xonly_pk;
@@ -4310,8 +4311,9 @@ void test_xonly_pubkey(void) {
43104311
CHECK(memcmp(&xonly_pk, &xonly_pk_tmp, sizeof(xonly_pk)) == 0);
43114312

43124313
/* Can't parse a byte string that's not a valid X coordinate */
4313-
memset(garbage, 0, sizeof(garbage));
4314-
CHECK(secp256k1_xonly_pubkey_parse(ctx, &xonly_pk_tmp, garbage) == 0);
4314+
memset(ones32, 0xFF, sizeof(ones32));
4315+
CHECK(secp256k1_xonly_pubkey_parse(ctx, &xonly_pk_tmp, ones32) == 0);
4316+
CHECK(memcmp(&xonly_pk_tmp, zeros64, sizeof(xonly_pk_tmp)) == 0);
43154317
}
43164318

43174319
void test_xonly_pubkey_api(void) {

0 commit comments

Comments
 (0)