| 234 | } |
| 235 | |
| 236 | bool CKey::VerifyPubKey(const CPubKey& pubkey) const { |
| 237 | if (pubkey.IsCompressed() != fCompressed) { |
| 238 | return false; |
| 239 | } |
| 240 | unsigned char rnd[8]; |
| 241 | std::string str = "Bitcoin key verification\n"; |
| 242 | GetRandBytes(rnd); |
| 243 | uint256 hash{Hash(str, rnd)}; |
| 244 | std::vector<unsigned char> vchSig; |
| 245 | Sign(hash, vchSig); |
| 246 | return pubkey.Verify(hash, vchSig); |
| 247 | } |
| 248 | |
| 249 | bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const { |
| 250 | if (!keydata) |