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

Method selfTest

CLKeySearchDevice/CLKeySearchDevice.cpp:428–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428void CLKeySearchDevice::selfTest()
429{
430 uint64_t numPoints = (uint64_t)_points;
431 std::vector<secp256k1::uint256> privateKeys;
432
433 // Generate key pairs for k, k+1, k+2 ... k + <total points in parallel - 1>
434 secp256k1::uint256 privKey = _start;
435
436 privateKeys.push_back(_start);
437
438 for(uint64_t i = 1; i < numPoints; i++) {
439 privKey = privKey.add(_stride);
440 privateKeys.push_back(privKey);
441 }
442
443 unsigned int *xBuf = new unsigned int[numPoints * 8];
444 unsigned int *yBuf = new unsigned int[numPoints * 8];
445
446 _clContext->copyDeviceToHost(_x, xBuf, sizeof(unsigned int) * 8 * numPoints);
447 _clContext->copyDeviceToHost(_y, yBuf, sizeof(unsigned int) * 8 * numPoints);
448
449 for(int index = 0; index < _points; index++) {
450 secp256k1::uint256 privateKey = privateKeys[index];
451
452 secp256k1::uint256 x = readBigInt(xBuf, index);
453 secp256k1::uint256 y = readBigInt(yBuf, index);
454
455 secp256k1::ecpoint p1(x, y);
456 secp256k1::ecpoint p2 = secp256k1::multiplyPoint(privateKey, secp256k1::G());
457
458 if(!secp256k1::pointExists(p1)) {
459 throw std::string("Validation failed: invalid point");
460 }
461
462 if(!secp256k1::pointExists(p2)) {
463 throw std::string("Validation failed: invalid point");
464 }
465
466 if(!(p1 == p2)) {
467 throw std::string("Validation failed: points do not match");
468 }
469 }
470}
471
472
473

Callers

nothing calls this directly

Calls 3

GFunction · 0.85
copyDeviceToHostMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected