Changeset View
Changeset View
Standalone View
Standalone View
src/pubkey.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | bool CPubKey::VerifyECDSA(const uint256 &hash, | ||||
} | } | ||||
secp256k1_pubkey pubkey; | secp256k1_pubkey pubkey; | ||||
secp256k1_ecdsa_signature sig; | secp256k1_ecdsa_signature sig; | ||||
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, | if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, | ||||
&(*this)[0], size())) { | &(*this)[0], size())) { | ||||
return false; | return false; | ||||
} | } | ||||
if (vchSig.size() == 0) { | |||||
return false; | |||||
} | |||||
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, | if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, | ||||
&vchSig[0], vchSig.size())) { | vchSig.data(), vchSig.size())) { | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* libsecp256k1's ECDSA verification requires lower-S signatures, which have | * libsecp256k1's ECDSA verification requires lower-S signatures, which have | ||||
* not historically been enforced in Bitcoin, so normalize them first. | * not historically been enforced in Bitcoin, so normalize them first. | ||||
*/ | */ | ||||
secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig); | secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig); | ||||
return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), | return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const { | ||||
out.nChild = _nChild; | out.nChild = _nChild; | ||||
return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode); | return pubkey.Derive(out.pubkey, out.chaincode, _nChild, chaincode); | ||||
} | } | ||||
bool CPubKey::CheckLowS( | bool CPubKey::CheckLowS( | ||||
const boost::sliced_range<const std::vector<uint8_t>> &vchSig) { | const boost::sliced_range<const std::vector<uint8_t>> &vchSig) { | ||||
secp256k1_ecdsa_signature sig; | secp256k1_ecdsa_signature sig; | ||||
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, | if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, | ||||
&vchSig[0], vchSig.size())) { | &vchSig.front(), vchSig.size())) { | ||||
return false; | return false; | ||||
} | } | ||||
return (!secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, | return (!secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, | ||||
nullptr, &sig)); | nullptr, &sig)); | ||||
} | } | ||||
/* static */ int ECCVerifyHandle::refcount = 0; | /* static */ int ECCVerifyHandle::refcount = 0; | ||||
Show All 18 Lines |