| 249 | } |
| 250 | |
| 251 | bool CKey::VerifyPubKey(const CPubKey& pubkey) const { |
| 252 | if (pubkey.IsCompressed() != fCompressed) { |
| 253 | return false; |
| 254 | } |
| 255 | unsigned char rnd[8]; |
| 256 | std::string str = "Bitcoin key verification\n"; |
| 257 | GetRandBytes(rnd, sizeof(rnd)); |
| 258 | uint256 hash; |
| 259 | CHash256().Write(MakeUCharSpan(str)).Write(rnd).Finalize(hash); |
| 260 | std::vector<unsigned char> vchSig; |
| 261 | Sign(hash, vchSig); |
| 262 | return pubkey.Verify(hash, vchSig); |
| 263 | } |
| 264 | |
| 265 | bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const { |
| 266 | if (!fValid) |