Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
ascripto
on 15/12/2024, 20:11:16 UTC
It seems that few people here have started researching and solving puzzles using Bitcoin private key WiFiI tested a great program, but I haven't made it public yet.

Hello @cctv5go , you found the prefix 1BY8GQbnueY in the 75X range. Which program did you use to do this? You said in the forum that you want to publish a program, which one can you tell me?

Many thanks, Merry Christmas

This type of search has a name, vanity.

I've already scanned a good part of the range and the closest thing is around 5XXXX.... (unless I'm mistaken) However, don't be fooled by appearances, if you go deeper into the curve generator to find an address that has a similar ertropy outside the range, this occurs by changing the bit on the 256 line 5 to 4 times, giving an average of 20%, which is close in terms of public key generation but distant numerically in relation to the range.

I'm going to leave a code here in Python for the terror of C programmers, it could be in Cobol but I prefer practicality.


import hashlib
import binascii
import ecdsa
import base58

# Função para converter hexadecimal para bytes
def hex_to_bytes(hex_string):
    return binascii.unhexlify(hex_string)

# Função para gerar um endereço Bitcoin a partir de uma chave privada
def private_key_to_address(private_key):
    private_key_bytes = hex_to_bytes(private_key)
   
    # Gera chave pública correspondente (ponto na curva elíptica)
    sk = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1)
    vk = sk.verifying_key
    public_key_bytes = b'\x04' + vk.to_string()
    print(f"Chave Pública (Hex): {binascii.hexlify(public_key_bytes).decode()}")

    # Executa SHA-256 e RIPEMD-160 na chave pública
    sha256_public_key = hashlib.sha256(public_key_bytes).digest()
    ripemd160_public_key = hashlib.new('ripemd160', sha256_public_key).digest()
    print(f"RIPEMD-160 da Chave Pública: {binascii.hexlify(ripemd160_public_key).decode()}")
   
    # Adiciona prefixo de rede (0x00 para mainnet)
    network_prefix = b'\x00'
    address_bytes = network_prefix + ripemd160_public_key
   
    # Calcula checksum
    checksum = hashlib.sha256(hashlib.sha256(address_bytes).digest()).digest()[:4]
    print(f"Checksum: {binascii.hexlify(checksum).decode()}")
   
    # Concatena endereço e checksum
    address_bytes += checksum
    print(f"Endereço com Checksum (Hex): {binascii.hexlify(address_bytes).decode()}")
   
    # Converte para formato Base58Check
    address = base58.b58encode(address_bytes).decode('utf-8')
    return address

# Função para encontrar um endereço de vanidade específico dentro de um intervalo de chaves
def find_vanity_address_within_range(pattern, start_range, end_range):
    start_value = int(start_range, 16)
    end_value = int(end_range, 16)
    for i in range(start_value, end_value + 1):
        private_key = format(i, 'x').zfill(64)
        address = private_key_to_address(private_key)
        if address.startswith(pattern):
            return private_key, address
    return None, None

# Especificar o padrão desejado
pattern = '1BY8GQbnueYofwSuFAT3USAhGjPrkxDdW9'  # Use um padrão específico se desejar
start_range = '40000000000000000'
end_range = '7ffffffffffffffff'

# Encontrar chave privada e endereço correspondente
private_key, address = find_vanity_address_within_range(pattern, start_range, end_range)
if private_key and address:
    print(f"Chave privada: {private_key}")
    print(f"Endereço: {address}")
else:
    print("Não foi possível encontrar um endereço com o padrão especificado no intervalo fornecido.")