Merge elementsproject/secp256k1-zkp#248: bppp: Fix and improve test for invalid sign byte

3372993060bfe914d828e13499fcd2763ef83dd5 bppp: Fix test for invalid sign byte (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 3372993060bfe914d828e13499fcd2763ef83dd5

Tree-SHA512: cfc317b47dc731b419cc88d0c5292cb6b3ca9e28c937d316f63940be6ad4607056ece81136ca1226f94dbf26cfe0492f5d27f4cfa473cf46898474b342a55593
This commit is contained in:
Jonas Nick 2023-07-21 07:19:48 +00:00
commit afe7e649ee
No known key found for this signature in database
GPG Key ID: 4861DBF262123605

View File

@ -257,7 +257,11 @@ void test_serialize_two_points(void) {
random_group_element_test(&X);
random_group_element_test(&R);
secp256k1_bppp_serialize_points(buf, &X, &R);
buf[0] |= 4 + (unsigned char)secp256k1_testrandi64(4, 255);
buf[0] = 4 + (unsigned char)secp256k1_testrandi64(0, 253);
/* Assert that buf[0] is actually invalid. */
CHECK(buf[0] != 0x02 && buf[0] != 0x03);
CHECK(!secp256k1_bppp_parse_one_of_points(&X_tmp, buf, 0));
CHECK(!secp256k1_bppp_parse_one_of_points(&R_tmp, buf, 0));
}