Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
alek76
on 08/10/2023, 12:01:55 UTC
   seed = random.getrandbits(128)
    seed_value = int(seed)
    random.seed(seed_value)
    seed = str(seed_value)

It's not even close to 128.

The closest I've come up with 8 to 2 ** 65

30568377238562584866, b'\xc9\xd9\x1d\xbc\x16\x9d\xdb\x86'

Code:
import random
puzzle = 65
lower_range_limit = 2 ** (puzzle - 1)
upper_range_limit = (2 ** puzzle) - 1
owner_salt = b'\xc9\xd9\x1d\xbc\x16\x9d\xdb\x86'
random.seed(owner_salt)
dec = random.randint(lower_range_limit, upper_range_limit)
print(f"{dec}, {owner_salt}")

but even so a part is missing to get a 100% accurate result. Grin

it seems most likely that pbkdf2_hmac was used

hashlib.pbkdf2_hmac('sha512', os.urandom(8 ), b'', iterations=1024)[:32]

some combination like this.
In that code, the 512-bit key is normalized by division modulo % CURVE_ORDER
from_arbitrary_size_secret()
Code:
def normalize_secret_bytes(cls, privkey_bytes: bytes) -> bytes:
        scalar = string_to_number(privkey_bytes) % CURVE_ORDER
        if scalar == 0:
            raise Exception('invalid EC private key scalar: zero')
        privkey_32bytes = number_to_string(scalar, CURVE_ORDER)
        return privkey_32bytes

As the creator said, you need to trim the high bytes of the key with zeros!