Merge commits '115b135f c8206b1c b6c2a3cd e7f7083b be5e4f02 5c751833 540fec8a aa2a39c1 8d445730 f9a944ff 2d9137ce 4721e077 471e3a13 ebb35882 1a53f496 c7a52400 ' into temp-merge-1809
This commit is contained in:
46
src/tests.c
46
src/tests.c
@@ -4291,9 +4291,9 @@ static void test_group_decompress(const secp256k1_fe* x) {
|
||||
secp256k1_fe_normalize_var(&ge_even.y);
|
||||
|
||||
/* No infinity allowed. */
|
||||
CHECK(!ge_quad.infinity);
|
||||
CHECK(!ge_even.infinity);
|
||||
CHECK(!ge_odd.infinity);
|
||||
CHECK(!secp256k1_ge_is_infinity(&ge_quad));
|
||||
CHECK(!secp256k1_ge_is_infinity(&ge_even));
|
||||
CHECK(!secp256k1_ge_is_infinity(&ge_odd));
|
||||
|
||||
/* Check that the x coordinates check out. */
|
||||
CHECK(secp256k1_fe_equal(&ge_quad.x, x));
|
||||
@@ -4477,8 +4477,6 @@ static void test_point_times_order(const secp256k1_gej *point) {
|
||||
secp256k1_scalar nx;
|
||||
secp256k1_gej res1, res2;
|
||||
secp256k1_ge res3;
|
||||
unsigned char pub[65];
|
||||
size_t psize = 65;
|
||||
testutil_random_scalar_order_test(&x);
|
||||
secp256k1_scalar_negate(&nx, &x);
|
||||
secp256k1_ecmult(&res1, point, &x, &x); /* calc res1 = x * point + x * G; */
|
||||
@@ -4488,9 +4486,6 @@ static void test_point_times_order(const secp256k1_gej *point) {
|
||||
secp256k1_ge_set_gej(&res3, &res1);
|
||||
CHECK(secp256k1_ge_is_infinity(&res3));
|
||||
CHECK(secp256k1_ge_is_valid_var(&res3) == 0);
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&res3, pub, &psize, 0) == 0);
|
||||
psize = 65;
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&res3, pub, &psize, 1) == 0);
|
||||
/* check zero/one edge cases */
|
||||
secp256k1_ecmult(&res1, point, &secp256k1_scalar_zero, &secp256k1_scalar_zero);
|
||||
secp256k1_ge_set_gej(&res3, &res1);
|
||||
@@ -5597,7 +5592,6 @@ static void test_ecmult_accumulate(secp256k1_sha256* acc, const secp256k1_scalar
|
||||
secp256k1_gej rj1, rj2, rj3, rj4, rj5, rj6, gj, infj;
|
||||
secp256k1_ge r;
|
||||
unsigned char bytes[65];
|
||||
size_t size = 65;
|
||||
secp256k1_gej_set_ge(&gj, &secp256k1_ge_const_g);
|
||||
secp256k1_gej_set_infinity(&infj);
|
||||
secp256k1_ecmult_gen(&CTX->ecmult_gen_ctx, &rj1, x);
|
||||
@@ -5618,9 +5612,8 @@ static void test_ecmult_accumulate(secp256k1_sha256* acc, const secp256k1_scalar
|
||||
secp256k1_sha256_write(acc, zerobyte, 1);
|
||||
} else {
|
||||
/* Store other points using their uncompressed serialization. */
|
||||
secp256k1_eckey_pubkey_serialize(&r, bytes, &size, 0);
|
||||
CHECK(size == 65);
|
||||
secp256k1_sha256_write(acc, bytes, size);
|
||||
secp256k1_eckey_pubkey_serialize65(&r, bytes);
|
||||
secp256k1_sha256_write(acc, bytes, sizeof(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6221,6 +6214,7 @@ static void run_eckey_edge_case_test(void) {
|
||||
secp256k1_pubkey pubkey_negone;
|
||||
const secp256k1_pubkey *pubkeys[3];
|
||||
size_t len;
|
||||
int i;
|
||||
/* Group order is too large, reject. */
|
||||
CHECK(secp256k1_ec_seckey_verify(CTX, orderc) == 0);
|
||||
SECP256K1_CHECKMEM_UNDEFINE(&pubkey, sizeof(pubkey));
|
||||
@@ -6414,6 +6408,14 @@ static void run_eckey_edge_case_test(void) {
|
||||
CHECK(secp256k1_ec_pubkey_combine(CTX, &pubkey, pubkeys, 3) == 1);
|
||||
SECP256K1_CHECKMEM_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(secp256k1_memcmp_var(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0);
|
||||
/* check that NULL in array of pubkey pointers is not allowed */
|
||||
for (i = 0; i < 3; i++) {
|
||||
const secp256k1_pubkey *original_ptr = pubkeys[i];
|
||||
secp256k1_pubkey result;
|
||||
pubkeys[i] = NULL;
|
||||
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_combine(CTX, &result, pubkeys, 3));
|
||||
pubkeys[i] = original_ptr;
|
||||
}
|
||||
len = 33;
|
||||
CHECK(secp256k1_ec_pubkey_serialize(CTX, ctmp, &len, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_serialize(CTX, ctmp2, &len, &pubkey_one, SECP256K1_EC_COMPRESSED) == 1);
|
||||
@@ -6705,16 +6707,18 @@ static void test_random_pubkeys(void) {
|
||||
size_t size = len;
|
||||
firstb = in[0];
|
||||
/* If the pubkey can be parsed, it should round-trip... */
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&elem, out, &size, len == 33));
|
||||
CHECK(size == len);
|
||||
if (len == 33) {
|
||||
secp256k1_eckey_pubkey_serialize33(&elem, out);
|
||||
} else {
|
||||
secp256k1_eckey_pubkey_serialize65(&elem, out);
|
||||
}
|
||||
CHECK(secp256k1_memcmp_var(&in[1], &out[1], len-1) == 0);
|
||||
/* ... except for the type of hybrid inputs. */
|
||||
if ((in[0] != 6) && (in[0] != 7)) {
|
||||
CHECK(in[0] == out[0]);
|
||||
}
|
||||
size = 65;
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&elem, in, &size, 0));
|
||||
CHECK(size == 65);
|
||||
secp256k1_eckey_pubkey_serialize65(&elem, in);
|
||||
CHECK(secp256k1_eckey_pubkey_parse(&elem2, in, size));
|
||||
CHECK(secp256k1_ge_eq_var(&elem2, &elem));
|
||||
/* Check that the X9.62 hybrid type is checked. */
|
||||
@@ -6729,7 +6733,7 @@ static void test_random_pubkeys(void) {
|
||||
}
|
||||
if (res) {
|
||||
CHECK(secp256k1_ge_eq_var(&elem, &elem2));
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&elem, out, &size, 0));
|
||||
secp256k1_eckey_pubkey_serialize65(&elem, out);
|
||||
CHECK(secp256k1_memcmp_var(&in[1], &out[1], 64) == 0);
|
||||
}
|
||||
}
|
||||
@@ -6807,6 +6811,7 @@ static void permute(size_t *arr, size_t n) {
|
||||
static void test_sort_api(void) {
|
||||
secp256k1_pubkey pks[2];
|
||||
const secp256k1_pubkey *pks_ptr[2];
|
||||
int i;
|
||||
|
||||
pks_ptr[0] = &pks[0];
|
||||
pks_ptr[1] = &pks[1];
|
||||
@@ -6815,6 +6820,13 @@ static void test_sort_api(void) {
|
||||
testutil_random_pubkey_test(&pks[1]);
|
||||
|
||||
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1);
|
||||
/* check that NULL in array of public key pointers is not allowed */
|
||||
for (i = 0; i < 2; i++) {
|
||||
const secp256k1_pubkey *original_ptr = pks_ptr[i];
|
||||
pks_ptr[i] = NULL;
|
||||
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2));
|
||||
pks_ptr[i] = original_ptr;
|
||||
}
|
||||
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_sort(CTX, NULL, 2));
|
||||
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 0) == 1);
|
||||
/* Test illegal public keys */
|
||||
|
||||
Reference in New Issue
Block a user