Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
tptkimikaze
on 12/08/2023, 19:35:45 UTC
Using this code below to find the private key for puzzle 30, which specifies that the first 4 bits are 1. Running it with 12 processes on my i7-12700kf, the private key was found in about 1 minute and 28 seconds.

Code:
000000000000000000000000000000000000000000000000000000003d94cd64
hash160: d39c4704664e1deb76c9331e637564c257d68a08
Target hash found!
Time: 0 h, 1 m, 28 s

Code:
import hashlib
import ecdsa
import random
import time
from multiprocessing import Process, Event

target_hash = "d39c4704664e1deb76c9331e637564c257d68a08"

def binary_to_hex(bin_string):
    return hex(int(bin_string, 2))[2:].zfill(len(bin_string) // 4)


def worker(num_zeros, num_ones, stop_event):


    while True:
        if stop_event.is_set():
            break

        bits = ['0'] * num_zeros + ['1'] * (num_ones - 4)
        random.shuffle(bits)

        bits.insert(0, '1')
        bits.insert(1, '1')
        bits.insert(2, '1')
        bits.insert(3, '1')
        private_key_bin = ''.join(bits)

        private_key_bin = '0' * (256 - 30) + private_key_bin

        private_key_hex = binary_to_hex(private_key_bin)

        sk = ecdsa.SigningKey.from_string(bytes.fromhex(private_key_hex), curve=ecdsa.SECP256k1)
        public_key = sk.get_verifying_key().to_string().hex()

        compressed_public_key = '02' + public_key[0:64] if int(public_key[-2:], 16) % 2 == 0 else '03' + public_key[0:64]
        compressed_public_key_bytes = bytes.fromhex(compressed_public_key)

        ripemd160_hash = hashlib.new('ripemd160')
        ripemd160_hash.update(hashlib.sha256(compressed_public_key_bytes).digest())
        hashed_compressed_public_key = ripemd160_hash.digest().hex()


        if hashed_compressed_public_key == target_hash:
            print(private_key_hex)
            print("hash160:", hashed_compressed_public_key)
            print("Target hash found!")

            stop_event.set()
            break



def main():
    num_processes = 12
    processes = []
    stop_event = Event()

    start_time = time.time()

    for _ in range(num_processes):
        process = Process(target=worker, args=(14, 16, stop_event))
        processes.append(process)

    for process in processes:
        process.start()

    for process in processes:
        process.join()

    if stop_event.is_set():
        for process in processes:
            process.terminate()

    end_time = time.time()
    execution_time_seconds = end_time - start_time

    hours = int(execution_time_seconds // 3600)
    minutes = int((execution_time_seconds % 3600) // 60)
    seconds = int(execution_time_seconds % 60)

    print(f"Time: {hours} h, {minutes} m, {seconds} s")



if __name__ == '__main__':
    main()

I just try it and I can find it in 30 sec on #30. For #66 it's still difficult to scan without GPU.

Try also for #35, #40, or #45.

Scan it in python without GPU too slow for 66 bit. The only way I can figure out now as I previous posted.

Step 1

Let's say start scanning from 60 bits. Use Python to do the combination.

0s - 30 - 1s -30 = 50%
0s - 31 - 1s  29 = 51.67%
0s - 32 - 1s  28 = 53.4%
0s - 33 - 1s  27 = 55%
0s - 34 - 1s  26 = 56.67%
0s - 35 - 1s  25 = 58.34%
0s - 36 - 1s  24 = 60%

Then reverse 0s and 1s position in max 60% which is most likely where the key are.

Step 2
Convert results from Binary to Hexa

Step 3
Make a batch file and run in Bitcrack to use GPU

Step 4
Run until it hits the key or else increase the percentages if it doesn't.

By using Python to eliminate those less like key first, then scan the list with GPU

Pro Python definitely have no problem with it but I'm not pro. Combine pro Python with GPU, I believe the results will be as Bestie said, achievable in 3 days.