Changeset View
Changeset View
Standalone View
Standalone View
src/key.cpp
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
bool CKey::VerifyPubKey(const CPubKey &pubkey) const { | bool CKey::VerifyPubKey(const CPubKey &pubkey) const { | ||||
if (pubkey.IsCompressed() != fCompressed) { | if (pubkey.IsCompressed() != fCompressed) { | ||||
return false; | return false; | ||||
} | } | ||||
uint8_t rnd[8]; | uint8_t rnd[8]; | ||||
std::string str = "Bitcoin key verification\n"; | std::string str = "Bitcoin key verification\n"; | ||||
GetRandBytes(rnd, sizeof(rnd)); | GetRandBytes(rnd, sizeof(rnd)); | ||||
uint256 hash; | uint256 hash; | ||||
CHash256() | CHash256().Write(MakeUCharSpan(str)).Write(rnd).Finalize(hash.begin()); | ||||
.Write((uint8_t *)str.data(), str.size()) | |||||
.Write(rnd, sizeof(rnd)) | |||||
.Finalize(hash.begin()); | |||||
std::vector<uint8_t> vchSig; | std::vector<uint8_t> vchSig; | ||||
SignECDSA(hash, vchSig); | SignECDSA(hash, vchSig); | ||||
return pubkey.VerifyECDSA(hash, vchSig); | return pubkey.VerifyECDSA(hash, vchSig); | ||||
} | } | ||||
bool CKey::SignCompact(const uint256 &hash, | bool CKey::SignCompact(const uint256 &hash, | ||||
std::vector<uint8_t> &vchSig) const { | std::vector<uint8_t> &vchSig) const { | ||||
if (!fValid) { | if (!fValid) { | ||||
▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines |