Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
zahid888
on 13/03/2025, 17:09:18 UTC
Thanks in Advance Smiley

I see you're started with the modification. Just to let you know in advance, I don't use #include "p2pkh_decoder.h" or p2pkh_decoder. Using them costs around 10-15 Mkeys/s in performance. Comparing HASH160 directly is much faster than decoding to a P2PKH address and then comparing. Additionally, it will be even slower if the comparison is based on the decoded address.

The --prefix argument is not being used in the script to filter addresses based on a specific prefix.


Code:
// You need function like this to extract the prefix from a P2PKH address
std::string extractPrefix(const std::string& address, size_t prefixLength) {
    return address.substr(0, prefixLength);
}

// Inside the parallel section
std::string generatedAddress = P2PKHDecoder::getAddressFromHash160(localHashResults[j]);
std::string generatedPrefix = extractPrefix(generatedAddress, prefixFilter.length());

if (generatedPrefix == prefixFilter) {
    // Prefix matches, now check if the address matches the target
    __m128i cand16 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(localHashResults[j]));
    __m128i cmp = _mm_cmpeq_epi8(cand16, target16);
    if (_mm_movemask_epi8(cmp) == 0xFFFF) {
        // Checking last 4 bytes (20 - 16)
        if (!matchFound && std::memcmp(localHashResults[j], targetHash160.data(), 20) == 0) {
            #pragma omp critical
            {
                if (!matchFound) {
                    matchFound = true;
                    auto tEndTime = std::chrono::high_resolution_clock::now();
                    globalElapsedTime = std::chrono::duration<double>(tEndTime - tStart).count();
                    mkeysPerSec = (double)(globalComparedCount + localComparedCount) / globalElapsedTime / 1e6;

                    // Recovering private key
                    Int matchingPrivateKey;
                    matchingPrivateKey.Set(&currentBatchKey);
                    int idx = pointIndices[j];
                    if (idx < 256) {
                        Int offset; offset.SetInt32(idx);
                        matchingPrivateKey.Add(&offset);
                    } else {
                        Int offset; offset.SetInt32(idx - 256);
                        matchingPrivateKey.Sub(&offset);
                    }
                    foundPrivateKeyHex = padHexTo64(intToHex(matchingPrivateKey));
                    Point matchedPoint = pointBatch[idx];
                    foundPublicKeyHex  = pointToCompressedHex(matchedPoint);
                    foundWIF = P2PKHDecoder::compute_wif(foundPrivateKeyHex, true);
                }
            }
            #pragma omp cancel parallel
        }
        localComparedCount++;
    } else {
        localComparedCount++;
    }
}


Implementing the stride option is even more challenging in such a complex AVX2 implementation, especially with so many if statements and batch operations.

I appreciate the suggestion! But trust me, it's not just a small tweak—it's like trying to upgrade a bicycle into a spaceship. The whole repo needs a serious overhaul just to make it work, and for a beginner like me, that’s like climbing Mount Everest in flip-flops! Grin Anyway, thanks for the idea!"