mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
pubkey: Assert CPubKey's ECCVerifyHandle precondition
This commit is contained in:
parent
be50469217
commit
d8daa8f371
1 changed files with 6 additions and 0 deletions
|
@ -171,6 +171,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchS
|
|||
return false;
|
||||
secp256k1_pubkey pubkey;
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -190,6 +191,7 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha
|
|||
bool fComp = ((vchSig[0] - 27) & 4) != 0;
|
||||
secp256k1_pubkey pubkey;
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -207,6 +209,7 @@ bool CPubKey::IsFullyValid() const {
|
|||
if (!IsValid())
|
||||
return false;
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -214,6 +217,7 @@ bool CPubKey::Decompress() {
|
|||
if (!IsValid())
|
||||
return false;
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -232,6 +236,7 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
|
|||
BIP32Hash(cc, nChild, *begin(), begin()+1, out);
|
||||
memcpy(ccChild.begin(), out+32, 32);
|
||||
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())) {
|
||||
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) {
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue