bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
vchSig.clear();
- auto sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
+ auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
if (sig==NULL)
return false;
auto group = EC_KEY_get0_group(pkey);
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y
-bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
+bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
{
bool fOk = false;
auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
// This is only slightly more CPU intensive than just verifying it.
// If this function succeeds, the recovered public key is guaranteed to be valid
// (the signature is a valid signature of the given data for that key)
-bool CPubKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::SetCompactSignature(const uint256 &hash, const std::vector<unsigned char>& vchSig)
{
if (vchSig.size() != 65)
return false;
return ret;
}
-bool CPubKey::VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::VerifyCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig)
{
CPubKey key;
if (!key.SetCompactSignature(hash, vchSig))
bnHash.setuint160(Hash160(vchLr));
CPoint pointH;
- pointH.setPubKey(pubKeyH);
+ if (!pointH.setPubKey(pubKeyH)) {
+ throw key_error("CMalleablePubKey::GetVariant() : Unable to decode H value");
+ }
CPoint P;
// Calculate P = Hash(L*r)*G + H
}
std::vector<unsigned char> vchResult;
- P.getBytes(vchResult);
+ if (!P.getBytes(vchResult)) {
+ throw key_error("CMalleablePubKey::GetVariant() : Unable to convert P value");
+ }
vchPubKeyVariant = CPubKey(vchResult);
}