Post
Topic
Board Bitcoin Discussion
Merits 1 from 1 user
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
mcdouglasx
on 29/08/2023, 22:10:19 UTC
⭐ Merited by digaran (1)



Code:
import secp256k1 as ice


target_public_key = "023d62d9d64a7164a2ae6f0561f7e8317e69b4a1ee61048fe768a1316b39b1d3a7"
target = ice.pub2upub(target_public_key)
num = 100 # number of times.
sustract= 1 #amount to subtract each time.
sustract_pub= ice.scalar_multiplication(sustract)
res= ice.point_loop_subtraction(num, target, sustract_pub)
for t in range (num+1):
    h= res[t*65:t*65+65]
    data = open("data-base.txt","a")
    data.write(str(h.hex())+"\n")
    data.close()



Is it possible to make it possible to specify an unlimited number in num?

If set num = 1000000000
That throws an error:

Traceback (most recent call last):
   File "D :\PubSub\PubSub.py", line 8, in <module>
     res= ice.point_loop_subtraction(num, target, sustract_pub).hex()
   File "D :\PubSub\secp256k1.py", line 504, in point_loop_subtraction
     res = _point_loop_subtraction(num, pubkey1_bytes, pubkey2_bytes)
   File "D :\PubSub\secp256k1.py", line 497, in _point_loop_subtraction
     res = (b'\x00') * (65 * num)
MemoryError

More importantly, how to get compressed public keys as result? Lol I changed *65:*65+65 to *32:*32+33 but it messed up everything.
The 65 refers to bytes, it is to put each 65 bytes of the result on a different line.

for compressed public keys
Code:
import secp256k1 as ice


target_public_key = "032f3342152eff6aca5e7314db6d3301a28d6a90ddcfd189f96babadc2a053d392"
target = ice.pub2upub(target_public_key)
num = 100 # number of times.
sustract= 1 #amount to subtract each time.
sustract_pub= ice.scalar_multiplication(sustract)
res= ice.point_loop_subtraction(num, target, sustract_pub)
for t in range (num+1):
    h= (res[t*65:t*65+65]).hex()
    hc= ice.to_cpub(h)
    data = open("data-base.txt","a")
    data.write(str(hc)+"\n")
    data.close()