Tags: cryptography-rsa
Rating:
# nameless (from idekCTF2021)
You can calculate (p+q)^2, (p-q)^2
because (p+q)^2 = p^2+q^2+2pq = p^2+q^2+2*n
and (p-q)^2 = p^2+q^2-2pq = p^2+q^2-2*n.
Once you know the two values above, you can easily calculate p, q.
Please check the code for detailed implementation.