| 213 | } |
| 214 | |
| 215 | bool CKey::VerifyPubKey(const CPubKey& pubkey) const { |
| 216 | if (pubkey.IsCompressed() != fCompressed) { |
| 217 | return false; |
| 218 | } |
| 219 | unsigned char rnd[8]; |
| 220 | std::string str = "Bitcoin key verification\n"; |
| 221 | GetRandBytes(rnd, sizeof(rnd)); |
| 222 | uint256 hash; |
| 223 | CHash256().Write((unsigned char*)str.data(), str.size()).Write(rnd, sizeof(rnd)).Finalize(hash.begin()); |
| 224 | std::vector<unsigned char> vchSig; |
| 225 | SignECDSA(hash, vchSig); |
| 226 | return pubkey.VerifyECDSA(hash, vchSig); |
| 227 | } |
| 228 | |
| 229 | bool CKey::SignCompact(const uint256& hash, std::vector<uint8_t>& vchSig) const { |
| 230 | if (!fValid) |