| 225 | } |
| 226 | |
| 227 | bool CKey::VerifyPubKey(const CPubKey& pubkey) const { |
| 228 | if (pubkey.IsCompressed() != fCompressed) { |
| 229 | return false; |
| 230 | } |
| 231 | unsigned char rnd[8]; |
| 232 | std::string str = "Bitcoin key verification\n"; |
| 233 | GetRandBytes(rnd, sizeof(rnd)); |
| 234 | uint256 hash; |
| 235 | CHash256().Write((unsigned char*)str.data(), str.size()).Write(rnd, sizeof(rnd)).Finalize(hash.begin()); |
| 236 | std::vector<unsigned char> vchSig; |
| 237 | Sign(hash, vchSig); |
| 238 | return pubkey.Verify(hash, vchSig); |
| 239 | } |
| 240 | |
| 241 | bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const { |
| 242 | if (!fValid) |