Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
Virtuose
on 18/03/2025, 07:40:04 UTC
Hi @Nomachine. I am curious about random mode in this code. is that the random totally fully random each keys or it similiar like keyhunt ?


The "random mode" is designed to generate private keys within a specified range using a pseudo-random number generator (PRNG). Specifically, it employs the Xoshiro256plus PRNG, a high-quality random number generator known for its speed.

Code:
Int generateRandomPrivateKey(Int minKey, Int range, Xoshiro256plus &rng) {
    Int randomPrivateKey((uint64_t)0);

    // Generate random values in chunks of 64 bits using Xoshiro256plus
    for (int i = 0; i < NB64BLOCK; ++i) {
        uint64_t randVal = rng.next();
        randomPrivateKey.ShiftL(64); // Shift left by 64 bits
        randomPrivateKey.Add(randVal);
    }

    // Apply modulo operation and add minKey
    randomPrivateKey.Mod(&range);
    randomPrivateKey.Add(&minKey);

    return randomPrivateKey;
}

The random keys are generated within a specific range defined by minKey and maxKey. These values are derived from the puzzle number or the provided range (via the -r argument or -p).

The generateRandomPrivateKey function ensures that the generated keys fall within this range by applying a modulo operation and adding minKey.

Code:
        while (!matchFound) {
            Int currentBatchKey;
            if (randomMode) {
                // Generate a random private key within the thread's range using Xoshiro256plus
                currentBatchKey = generateRandomPrivateKey(minKey, range, rng);
            } else {
                // Sequential mode
                if (intGreater(privateKey, threadRangeEnd)) {
                    break;
                }
                currentBatchKey.Set(&privateKey);
            }

Each thread initializes its own instance of the Xoshiro256plus PRNG with a unique seed. This ensures that the random sequences generated by different threads do not overlap and remain independent of one another.

Code:
    // PARRALEL COMPUTING BLOCK
#pragma omp parallel num_threads(numThreads) \
    shared(globalComparedCount, globalElapsedTime, mkeysPerSec, matchFound, \
           foundPrivateKeyHex, foundPublicKeyHex, lastStatusTime, lastSaveTime, g_progressSaveCount, \
           g_threadPrivateKeys)
    {
        const int threadId = omp_get_thread_num();

        // Initialize Xoshiro256plus PRNG for this thread
        Xoshiro256plus rng(std::chrono::steady_clock::now().time_since_epoch().count() + threadId);

        Int privateKey = hexToInt(g_threadRanges[threadId].startHex);
        const Int threadRangeEnd = hexToInt(g_threadRanges[threadId].endHex);

#pragma omp critical
        {
            g_threadPrivateKeys[threadId] = padHexTo64(intToHex(privateKey));
        }

The keys are distributed uniformly across the range.

Therefore, this process is entirely random, consistent with the approach I always use in all my scripts.

This script is a waste of time... You can't find a pvk based on prefix because it's just not possible and make non sense..
It would be more sensible to create a hybrid semi-sequential, semi-random search. Since you can find 6 nibbles instantly (only 16 million possibilities), you can gain 6 nibbles in your search if you give a few milliseconds for the random part to run. You would save a lot of time. And depending on your machine, you could save 8 or more with Cuda.