| 182 | } |
| 183 | |
| 184 | bool CKey::VerifyPubKey(const CPubKey& pubkey) const { |
| 185 | if (pubkey.IsCompressed() != fCompressed) { |
| 186 | return false; |
| 187 | } |
| 188 | unsigned char rnd[8]; |
| 189 | std::string str = "Bitcoin key verification\n"; |
| 190 | GetRandBytes(rnd, sizeof(rnd)); |
| 191 | uint256 hash; |
| 192 | CHash256().Write((unsigned char*)str.data(), str.size()).Write(rnd, sizeof(rnd)).Finalize(hash.begin()); |
| 193 | std::vector<unsigned char> vchSig; |
| 194 | Sign(hash, vchSig); |
| 195 | return pubkey.Verify(hash, vchSig); |
| 196 | } |
| 197 | |
| 198 | bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const { |
| 199 | if (!fValid) |