I did not manage to solve this challenge. The private key is composed by some
This means that there exists a
We have the observation that
We can use Gauss reduction to find the lattice generated by
Sage Implementation: (kudos to Drago
)
xxxxxxxxxx
from Crypto.Util.number import long_to_bytes
def decrypt(q, h, f, g, e):
a = (f*e) % q
m = (a*inverse_mod(f, g)) % g
return m
def gauss(v1, v2):
while True:
if v2.norm() < v1.norm():
v1, v2 = v2, v1
m = round(v1*v2/(v1*v1))
if m == 0:
return v1, v2
v2 = v2-m*v1
h, q = (2163268902194560093843693572170199707501787797497998463462129592239973581462651622978282637513865274199374452805292639586264791317439029535926401109074800, 7638232120454925879231554234011842347641017888219021175304217358715878636183252433454896490677496516149889316745664606749499241420160898019203925115292257)
enc_flag = 5605696495253720664142881956908624307570671858477482119657436163663663844731169035682344974286379049123733356009125671924280312532755241162267269123486523
g = gauss(vector([q,1]),vector([h,1]))[0][0]
F = IntegerModRing(q)
f = int(g / F(h))
print(long_to_bytes(decrypt(q,h,f,g,enc_flag)))