MCPcopy Create free account
hub / github.com/brichard19/BitCrack / verifyKey

Method verifyKey

CudaKeySearchDevice/CudaKeySearchDevice.cpp:269–299  ·  view source on GitHub ↗

Verify a private key produces the public key and hash

Source from the content-addressed store, hash-verified

267
268// Verify a private key produces the public key and hash
269bool 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
301size_t CudaKeySearchDevice::getResults(std::vector<KeySearchResult> &resultsOut)
302{

Callers

nothing calls this directly

Calls 2

GFunction · 0.85
exportWordsMethod · 0.80

Tested by

no test coverage detected