Skip to content

Commit e19aea6

Browse files
committed
Fixed bug where clBitCrack was not obeying --stride option
1 parent 5219fe7 commit e19aea6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CLKeySearchDevice/CLKeySearchDevice.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ void CLKeySearchDevice::init(const secp256k1::uint256 &start, int compression, u
195195

196196
_start = start;
197197

198+
_stride = stride;
199+
198200
_compression = compression;
199201

200202
allocateBuffers();
@@ -415,8 +417,7 @@ void CLKeySearchDevice::getResultsInternal()
415417
KeySearchResult minerResult;
416418

417419
// Calculate the private key based on the number of iterations and the current thread
418-
//secp256k1::uint256 offset((uint64_t)_blocks * _threads * _pointsPerThread * _iterations + getPrivateKeyOffset(ptr[i].thread, ptr[i].block, ptr[i].idx));
419-
secp256k1::uint256 offset = (secp256k1::uint256((uint64_t)_blocks * _threads * _pointsPerThread * _iterations) + secp256k1::uint256(getPrivateKeyOffset(ptr[i].thread, ptr[i].block, ptr[i].idx))) * _stride;
420+
secp256k1::uint256 offset = (secp256k1::uint256((uint64_t)_blocks * _threads * _pointsPerThread * _iterations) + secp256k1::uint256(getPrivateKeyOffset(ptr->thread, ptr->block, ptr->idx))) * _stride;
420421
secp256k1::uint256 privateKey = secp256k1::addModN(_start, offset);
421422

422423
minerResult.privateKey = privateKey;
@@ -588,8 +589,11 @@ void CLKeySearchDevice::generateStartingPoints()
588589
// Generate key pairs for k, k+1, k+2 ... k + <total points in parallel - 1>
589590
secp256k1::uint256 privKey = _start;
590591

591-
for(uint64_t i = 0; i < totalPoints; i++) {
592-
exponents.push_back(privKey.add(i));
592+
exponents.push_back(privKey);
593+
594+
for(uint64_t i = 1; i < totalPoints; i++) {
595+
privKey = privKey.add(_stride);
596+
exponents.push_back(privKey);
593597
}
594598

595599
unsigned int *privateKeys = new unsigned int[8 * totalPoints];

CudaKeySearchDevice/CudaKeySearchDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void CudaKeySearchDevice::getResultsInternal()
245245
KeySearchResult minerResult;
246246

247247
// Calculate the private key based on the number of iterations and the current thread
248-
secp256k1::uint256 offset = (secp256k1::uint256((uint64_t)_blocks * _threads * _pointsPerThread * _iterations) + secp256k1::uint256(getPrivateKeyOffset(rPtr->thread, rPtr->block, rPtr->idx)))* _stride;
248+
secp256k1::uint256 offset = (secp256k1::uint256((uint64_t)_blocks * _threads * _pointsPerThread * _iterations) + secp256k1::uint256(getPrivateKeyOffset(rPtr->thread, rPtr->block, rPtr->idx))) * _stride;
249249
secp256k1::uint256 privateKey = secp256k1::addModN(_startExponent, offset);
250250

251251
minerResult.privateKey = privateKey;

0 commit comments

Comments
 (0)