Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
MoreForUs
on 26/10/2023, 13:46:18 UTC
Code:
import ecdsa
import hashlib
import base58
import random
import time

def generate_bitcoin_address(private_key_hex):
    private_key = ecdsa.SigningKey.from_string(bytes.fromhex(private_key_hex), curve=ecdsa.SECP256k1)
    public_key = private_key.get_verifying_key()
    public_key_bytes = public_key.to_string("compressed")
   
    sha256_hash = hashlib.sha256(public_key_bytes)
    ripemd160_hash = hashlib.new("ripemd160")
    ripemd160_hash.update(sha256_hash.digest())
    bitcoin_address = ripemd160_hash.digest()

    # Mainnet prefix (0x00)
    network_byte = b'\x00'
    bitcoin_address = network_byte + bitcoin_address

    # Double SHA-256 hash for checksum
    checksum = hashlib.sha256(hashlib.sha256(bitcoin_address).digest()).digest()[:4]
   
    bitcoin_address += checksum
   
    base58_address = base58.b58encode(bitcoin_address)

    return base58_address.decode()

# Define the lower and upper bounds for the private key hex range
lower_bound = '20000000000000000'
upper_bound = '2ffffffffffffffff'
batch_size = 1000  # Number of private keys to search in each batch
total_parts = 100 # Total number of parts to break the range into

# Calculate the part size to make them equal
start_int = int(lower_bound, 16)
end_int = int(upper_bound, 16)
total_keys = end_int - start_int
part_size = total_keys // total_parts

# Generate a list of parts to search and reverse it
parts_to_search = [i for i in range(total_parts)][::-1]

target_addresses = ['13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so', '1BY8GQbnueYofwSuFAT3USAhGjPrkxDdW9', '1MVDYgVaSN6iKKEsbzRUAYFrYJadLYZvvZ']

additional_hex_numbers = ['2','3','4','5','6','7','8','9','a','b','c','d','e','f']

update_interval = 1
iteration_count = 0

found_addresses = set()

for current_part in parts_to_search:
    current_private_key_hex_start = start_int + current_part * part_size
    current_private_key_hex_end = current_private_key_hex_start + part_size
    iteration_start_time = time.time()

    while time.time() - iteration_start_time < 30:  # Iterate for 15 seconds
        if current_private_key_hex_start >= current_private_key_hex_end:
            break

        private_key_hex = hex(current_private_key_hex_start)[2:].zfill(64)  # Ensure the hex string is 64 characters long

        # Check if the private_key_hex contains non-hexadecimal characters
        if all(c in '0123bcdef' for c in private_key_hex):
            bitcoin_address = generate_bitcoin_address(private_key_hex)
            iteration_count += 1

            if iteration_count % update_interval == 0:
                print(f"Current Iteration Count: {iteration_count}")
                print(f"Current Private Key Hex: {private_key_hex}")
                print(f"Current Bitcoin Address: {bitcoin_address}")

            if bitcoin_address in target_addresses:
                print(f"Target address found: {bitcoin_address}")
                print(f"Private Key Hex: {private_key_hex}")
                found_addresses.add((bitcoin_address, private_key_hex))
                with open("found_addresses.txt", "a") as file:
                    file.write(f"Address: {bitcoin_address}, Private Key: {private_key_hex}\n")
                break

        found_match = False
        for hex_number in additional_hex_numbers:
            modified_private_key_hex = private_key_hex.replace('2', hex_number, 1).zfill(64)

            # Check if the modified_private_key_hex contains non-hexadecimal characters
            if all(c in '0123456789abcdef' for c in modified_private_key_hex):
                modified_bitcoin_address = generate_bitcoin_address(modified_private_key_hex)
                iteration_count += 1

                if iteration_count % update_interval == 0:
                    print(f"Current Iteration Count: {iteration_count}")
                    print(f"Current Private Key Hex (Modified): {modified_private_key_hex}")
                    print(f"Current Bitcoin Address (Modified): {modified_bitcoin_address}")

                if modified_bitcoin_address in target_addresses:
                    print(f"Target address found (Modified): {modified_bitcoin_address}")
                    print(f"Modified Private Key Hex: {modified_private_key_hex}")
                    found_addresses.add((modified_bitcoin_address, modified_private_key_hex))
                    with open("found_addresses.txt", "a") as file:
                        file.write(f"Address: {modified_bitcoin_address}, Private Key: {modified_private_key_hex}\n")
                    found_match = True
                    break
       
        if found_match:
            break
   
        current_private_key_hex_start += -1
Lets make some noise  Huh Shocked