Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
TheMissingNTLDR
on 23/02/2025, 22:42:40 UTC
Just looking to optimize my code for random pk search for Puzzle 68, any suggestions or comments greatly appreciated Smiley

Or any suggestions on how to make this run from my graphics card please? (Using Ubuntu at moment)

First, for this I have a local secp256k1 module in a folder on same level as this py file pasted below: https://github.com/iceland2k14/secp256k1


Code:
from pathlib import Path
import sys

path_root = Path(__file__).parents[2]
sys.path.append(str(path_root))
import btc.mymodules.mySECP256k1.secp256k1 as ice

import random

targetH160_68 = "e0b8a2baee1b77fc703455f39d51477451fc8cfc"

# 80000000000000000:fffffffffffffffff # 17 digits each

global_count = 0


def random_256():
    return "".join([random.choice("0123456789abcdef") for _ in range(16)])


while True:
    hex_256_16 = random_256()

    for i in ["8", "9", "a", "b", "c", "d", "e", "f"]:

        global_count += 1

        hex_256 = str(i) + str(hex_256_16)

        dec = int(hex_256, 16)

        h160_c = ice.privatekey_to_h160(0, True, dec).hex()

        if global_count % 100000 == 0:
            print(
                f"\r",
                f"{int(global_count):,}",
                f"{str(hex_256)}",
                end=" ",
            )

        if h160_c == targetH160_68:
            with open("./found.txt", "a") as file:
                file.write(
                    "Dec: "
                    + str(dec)
                    + " HexPK: "
                    + str(hex_256)
                    + " H160_c: "
                    + str(h160_c)
                    + "\n"
                )
            print("found!!")