Verify a private key produces the public key and hash
| 267 | |
| 268 | // Verify a private key produces the public key and hash |
| 269 | bool CudaKeySearchDevice::verifyKey(const secp256k1::uint256 &privateKey, const secp256k1::ecpoint &publicKey, const unsigned int hash[5], bool compressed) |
| 270 | { |
| 271 | secp256k1::ecpoint g = secp256k1::G(); |
| 272 | |
| 273 | secp256k1::ecpoint p = secp256k1::multiplyPoint(privateKey, g); |
| 274 | |
| 275 | if(!(p == publicKey)) { |
| 276 | return false; |
| 277 | } |
| 278 | |
| 279 | unsigned int xWords[8]; |
| 280 | unsigned int yWords[8]; |
| 281 | |
| 282 | p.x.exportWords(xWords, 8, secp256k1::uint256::BigEndian); |
| 283 | p.y.exportWords(yWords, 8, secp256k1::uint256::BigEndian); |
| 284 | |
| 285 | unsigned int digest[5]; |
| 286 | if(compressed) { |
| 287 | Hash::hashPublicKeyCompressed(xWords, yWords, digest); |
| 288 | } else { |
| 289 | Hash::hashPublicKey(xWords, yWords, digest); |
| 290 | } |
| 291 | |
| 292 | for(int i = 0; i < 5; i++) { |
| 293 | if(digest[i] != hash[i]) { |
| 294 | return false; |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | size_t CudaKeySearchDevice::getResults(std::vector<KeySearchResult> &resultsOut) |
| 302 | { |
nothing calls this directly
no test coverage detected