mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-28 23:08:52 +01:00
pubkey: Assert CPubKey's ECCVerifyHandle precondition
This commit is contained in:
@@ -171,6 +171,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchS
|
|||||||
return false;
|
return false;
|
||||||
secp256k1_pubkey pubkey;
|
secp256k1_pubkey pubkey;
|
||||||
secp256k1_ecdsa_signature sig;
|
secp256k1_ecdsa_signature sig;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -190,6 +191,7 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha
|
|||||||
bool fComp = ((vchSig[0] - 27) & 4) != 0;
|
bool fComp = ((vchSig[0] - 27) & 4) != 0;
|
||||||
secp256k1_pubkey pubkey;
|
secp256k1_pubkey pubkey;
|
||||||
secp256k1_ecdsa_recoverable_signature sig;
|
secp256k1_ecdsa_recoverable_signature sig;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
if (!secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_context_verify, &sig, &vchSig[1], recid)) {
|
if (!secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_context_verify, &sig, &vchSig[1], recid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -207,6 +209,7 @@ bool CPubKey::IsFullyValid() const {
|
|||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return false;
|
return false;
|
||||||
secp256k1_pubkey pubkey;
|
secp256k1_pubkey pubkey;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
return secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size());
|
return secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +217,7 @@ bool CPubKey::Decompress() {
|
|||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return false;
|
return false;
|
||||||
secp256k1_pubkey pubkey;
|
secp256k1_pubkey pubkey;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -232,6 +236,7 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
|
|||||||
BIP32Hash(cc, nChild, *begin(), begin()+1, out);
|
BIP32Hash(cc, nChild, *begin(), begin()+1, out);
|
||||||
memcpy(ccChild.begin(), out+32, 32);
|
memcpy(ccChild.begin(), out+32, 32);
|
||||||
secp256k1_pubkey pubkey;
|
secp256k1_pubkey pubkey;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -273,6 +278,7 @@ bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
|
|||||||
|
|
||||||
/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
|
/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
|
||||||
secp256k1_ecdsa_signature sig;
|
secp256k1_ecdsa_signature sig;
|
||||||
|
assert(secp256k1_context_verify && "secp256k1_context_verify must be initialized to use CPubKey.");
|
||||||
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) {
|
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user