- Round: 30 (2023/01)
- Category: Crypto
- Points: 75
- Solves: 25
Another boring RSA challenge
p=x^2+1
and q=x^2+1
so isqrt(n,2)
is a good approximation of x*y
, then you get phi(n)=x^2*y^2
so you can compute d
to decrypt the flag.
from Crypto.Util.number import long_to_bytes
import gmpy2
with open('output.txt') as f:
exec(f.read())
xy = gmpy2.iroot(n, 2)[0] - 1
phi = xy**2
d = gmpy2.invert(e, phi)
m = pow(c, d, n)
print(long_to_bytes(m))
@sahuang found that there is a generalization of this challenge: A New Attack on Special-Structured RSA Primes (Paper)
Found with keyword: near-square RSA primes
Proving
On the other way, I can't prove that
But assuming
So we know