|
|
|
@ -1871,7 +1871,7 @@ void test_ecdsa_end_to_end(void) {
|
|
|
|
|
CHECK(secp256k1_ec_pubkey_parse(ctx, &pubkey, pubkeyc, pubkeyclen) == 1);
|
|
|
|
|
|
|
|
|
|
/* Verify private key import and export. */
|
|
|
|
|
CHECK(secp256k1_ec_privkey_export(ctx, seckey, &seckeylen, privkey, secp256k1_rand32() % 2) == 1);
|
|
|
|
|
CHECK(secp256k1_ec_privkey_export(ctx, seckey, &seckeylen, privkey, (secp256k1_rand32() % 2) == 1) ? SECP256K1_EC_COMPRESSED : 0);
|
|
|
|
|
CHECK(secp256k1_ec_privkey_import(ctx, privkey2, seckey, seckeylen) == 1);
|
|
|
|
|
CHECK(memcmp(privkey, privkey2, 32) == 0);
|
|
|
|
|
|
|
|
|
@ -1979,7 +1979,7 @@ 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(secp256k1_eckey_pubkey_serialize(&elem, out, &size, (len == 33) ? SECP256K1_EC_COMPRESSED : 0));
|
|
|
|
|
CHECK(size == len);
|
|
|
|
|
CHECK(memcmp(&in[1], &out[1], len-1) == 0);
|
|
|
|
|
/* ... except for the type of hybrid inputs. */
|
|
|
|
@ -2156,7 +2156,7 @@ void test_ecdsa_edge_cases(void) {
|
|
|
|
|
size_t outlen = 300;
|
|
|
|
|
CHECK(!secp256k1_ec_privkey_export(ctx, privkey, &outlen, seckey, 0));
|
|
|
|
|
outlen = 300;
|
|
|
|
|
CHECK(!secp256k1_ec_privkey_export(ctx, privkey, &outlen, seckey, 1));
|
|
|
|
|
CHECK(!secp256k1_ec_privkey_export(ctx, privkey, &outlen, seckey, SECP256K1_EC_COMPRESSED));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2171,7 +2171,7 @@ EC_KEY *get_openssl_key(const secp256k1_scalar_t *key) {
|
|
|
|
|
const unsigned char* pbegin = privkey;
|
|
|
|
|
int compr = secp256k1_rand32() & 1;
|
|
|
|
|
EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_secp256k1);
|
|
|
|
|
CHECK(secp256k1_eckey_privkey_serialize(&ctx->ecmult_gen_ctx, privkey, &privkeylen, key, compr));
|
|
|
|
|
CHECK(secp256k1_eckey_privkey_serialize(&ctx->ecmult_gen_ctx, privkey, &privkeylen, key, compr ? SECP256K1_EC_COMPRESSED : 0));
|
|
|
|
|
CHECK(d2i_ECPrivateKey(&ec_key, &pbegin, privkeylen));
|
|
|
|
|
CHECK(EC_KEY_check_key(ec_key));
|
|
|
|
|
return ec_key;
|
|
|
|
|