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.
000000000000000000000000000000000000000000000000000000003d94cd64
hash160: d39c4704664e1deb76c9331e637564c257d68a08
Target hash found!
Time: 0 h, 1 m, 28 s
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.