The only promising code I have seen in a long time is the one mc posted, searching for either 02, or 03 public keys, if it was 02, ignore and discard, if it was 03, generate rmd160 to compare. That's the half of key space.
search for "02" or "03" and we would be dividing the area into 4.
but it's lucky that you find the right combination
I have that option in this script.
You can change as you like:
public_key_hex = ('02' and '03' if compressed else '04') + format(public_key[0], '064x') '02' and '03' together
public_key_hex = ('02' or '03' if compressed else '04') + format(public_key[0], '064x') '02' or '03' / '03' or '02'
public_key_hex = ('02' if compressed else '04') + format(public_key[0], '064x') only '02'
public_key_hex = ('03' if compressed else '04') + format(public_key[0], '064x') only '03'
No secp256k1 as ice, no ecdsa here.... Even encode base58 is custom with mpz.
And it's not slower than iceland - it's the same...
import hashlib, sys, os, time, random, gmpy2
from functools import lru_cache
# Constants as mpz
Gx = gmpy2.mpz('0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798', 16)
Gy = gmpy2.mpz('0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8', 16)
p = gmpy2.mpz('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F', 16)
n = gmpy2.mpz('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', 16)
@lru_cache(maxsize=None)
def private_key_to_public_key(private_key):
Q = point_multiply(Gx, Gy, private_key, p)
return Q
def point_multiply(x, y, k, p):
result = (gmpy2.mpz(0), gmpy2.mpz(0))
addend = (x, y)
while k > 0:
if k & 1:
result = point_add(result, addend, p)
addend = point_double(addend, p)
k >>= 1
return result
def point_double(point, p):
x, y = point
lmbda = (3 * x * x * gmpy2.powmod(2 * y, -1, p)) % p
x3 = (lmbda * lmbda - 2 * x) % p
y3 = (lmbda * (x - x3) - y) % p
return x3, y3
def point_add(point1, point2, p):
x1, y1 = point1
x2, y2 = point2
if point1 == (gmpy2.mpz(0), gmpy2.mpz(0)):
return point2
if point2 == (gmpy2.mpz(0), gmpy2.mpz(0)):
return point1
if point1 != point2:
lmbda = ((y2 - y1) * gmpy2.powmod(x2 - x1, -1, p)) % p
else:
lmbda = ((3 * x1 * x1) * gmpy2.powmod(2 * y1, -1, p)) % p
x3 = (lmbda * lmbda - x1 - x2) % p
y3 = (lmbda * (x1 - x3) - y1) % p
return x3, y3
def encode_base58(byte_str):
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)
long_value = gmpy2.mpz(int.from_bytes(byte_str, byteorder='big'))
result = ''
while long_value >= __b58base:
div, mod = gmpy2.f_divmod(long_value, __b58base)
result = __b58chars[int(mod)] + result
long_value = div
result = __b58chars[int(long_value)] + result
# Add leading '1's for zero bytes
nPad = 0
for byte in byte_str:
if byte == 0:
nPad += 1
else:
break
return __b58chars[0] * nPad + result
def public_key_to_hex(public_key, compressed=True):
x_hex = format(public_key[0], '064x')[2:] # Remove '0x' prefix
if compressed:
return ('02' if public_key[1] % 2 == 0 else '03') + x_hex
def public_key_to_address(public_key, compressed=True):
public_key_hex = ('02' and '03' if compressed else '04') + format(public_key[0], '064x')
sha256_hash = hashlib.sha256(bytes.fromhex(public_key_hex)).digest()
ripemd160_hash = hashlib.new('ripemd160', sha256_hash).digest()
versioned_hash = (b'\x00' if compressed else b'\x04') + ripemd160_hash
checksum = hashlib.sha256(hashlib.sha256(versioned_hash).digest()).digest()[:4]
address_bytes = versioned_hash + checksum
return encode_base58(address_bytes)
# Configuration for the puzzle
puzzle = 30
add = '1LHtnpd8nU5VHEMkG2TMYYNUjjLc992bps'
lower_range_limit = 2 ** (puzzle - 1);upper_range_limit = (2 ** puzzle) - 1
if os.name=='nt':os.system('cls')
else:os.system('clear')
t = time.ctime();sys.stdout.write(f"\033[?25l");sys.stdout.write(f"\033[01;33m[+] STARTED: {t}\n")
sys.stdout.write(f"[+] Puzzle: {puzzle}\n")
sys.stdout.write(f"[+] Lower range limit: {lower_range_limit}\n")
sys.stdout.write(f"[+] Upper range limit: {upper_range_limit}\n")
while True:
constant_prefix = b'yx\xcb\x08\xb70'
prefix_length = len(constant_prefix);length = 8
ending_length = length - prefix_length;ending_bytes = os.urandom(ending_length)
random_bytes = constant_prefix + ending_bytes
random.seed(random_bytes)
key = random.randint(lower_range_limit, upper_range_limit)
public_key = private_key_to_public_key(key)
bitcoin_address = public_key_to_address(public_key, compressed=True)
public_key = public_key_to_hex(public_key)
message = "[+] {}".format(key);messages = [];messages.append(message);output = ''.join(messages) + "\r";sys.stdout.write(output);sys.stdout.flush()
if bitcoin_address == add:
t = time.ctime()
sys.stdout.write("\n")
sys.stdout.write(f"\033[01;32m[+] SOLVED: {t}\n[+] Private Key (dec): {key}\n[+] Random Seed: {random_bytes}\033[0m\n")
with open('KEYFOUNDKEYFOUND.txt', 'a') as file:
file.write(f"Private Key (dec): {key}\nBitcoin Address (Compressed): {bitcoin_address}\nPublic Key: {public_key}\nRandom Seed: {random_bytes}\n\n")
break
- STARTED: Sat Nov 25 16:05:19 2023
- Puzzle: 30
- Lower range limit: 536870912
- Upper range limit: 1073741823
- 1033162084
- SOLVED: Sat Nov 25 16:05:21 2023
- Private Key (dec): 1033162084