is this puzzle still unsolved to date?
It's not one puzzle, there are 160 in total, some of them are already solved, #66 is not yet solved. #130 also not solved but these 2 are next in line.
Guys anyone here knows python? Of course you do, I'm stuck for days to make this happening, at first I wanted to have such function inside another script but I failed, so I thought of something else, the following script opens 2 text files, reads the keys in both and subtracts them from each other, that's the logic but whatever I did I couldn't get it to take public keys from each line of the files and do the subtraction with them all, it just reads the last line and returns only 1 result obviously, if you could provide a fix, it'd be great.
# secp256k1 curve parameters
p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
a = 0
b = 7
Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
# Point addition and subtraction functions
def point_add(P, Q):
if P == Q:
return point_double(P)
if P is None:
return Q
if Q is None:
return P
lam = ((Q[1] - P[1]) * pow(Q[0] - P[0], p-2, p)) % p
x = (lam * lam - P[0] - Q[0]) % p
y = (lam * (P[0] - x) - P[1]) % p
return (x, y)
def point_sub(P, Q):
if Q is None:
return P
# instead of using p - Q[1], use -Q[1] % p to correctly compute y coordinate
Q_neg = (Q[0], (-Q[1]) % p)
return point_add(P, Q_neg)
# Point doubling function
def point_double(P):
if P is None:
return None
lam = ((3 * P[0] * P[0] + a) * pow(2 * P[1], p-2, p)) % p
x = (lam * lam - 2 * P[0]) % p
y = (lam * (P[0] - x) - P[1]) % p
return (x, y)
def is_valid_point(point):
# Check that the point is not the point at infinity
if point is None:
return False
x, y = point
# Check that the coordinates are within the allowed range
if x < 0 or x >= p or y < 0 or y >= p:
return False
# Check that the point lies on the curve
return (y*y - x*x*x - a*x - b) % p == 0
def decompress_point(compressed_key):
if compressed_key.startswith(b'\x02') or compressed_key.startswith(b'\x03'):
x = int.from_bytes(compressed_key[1:], byteorder='big')
y_sq = (x * x * x + a*x + b) % p
y = pow(y_sq, (p+1)//4, p)
if (y*y) % p == y_sq:
return (x, y)
else:
return None
else:
return None
def compress_point(point):
x, y = point
prefix = b'\x02' if y % 2 == 0 else b'\x03'
return prefix + x.to_bytes(32, byteorder='big')
def point_subtraction(compressed_keys):
P = None
for compressed_key in compressed_keys:
Q = decompress_point(compressed_key)
# Check that the point is valid on the curve
if not is_valid_point(Q):
return None
if P is None:
P = Q
else:
P = point_sub(P, Q)
# Check that the resulting point is not the point at infinity
if P is None:
return None
if is_valid_point(P):
return compress_point(P)
else:
return None
compressed_keys = []
file1 = open('file1.txt', 'r')
for line in file1:
compressed_keys.append(bytes.fromhex(line.strip()))
file1.close()
file2 = open('file2.txt', 'r')
for line in file2:
compressed_keys.append(bytes.fromhex(line.strip()))
file2.close()
result = point_subtraction(compressed_keys)
if result:
file3 = open('result.txt', 'a')
file3.write(result.hex() + "\n")
file3.close()
else:
print("The subtraction result is not a valid point on the curve.")
I know the problem is in line.strip section, just don't know how, btw I asked AI, it started by implementing sha256 for no reason, ended up with giving me some test cases from bitcoin wiki. Go figure!
Note, it's for academic purposes only ( whatever that means anyway ).😉