# Is it safe to re-use the same p and q to generate a new pair of keys in RSA if the old private key was compromised?

Say I selected two large primes p and q for RSA and computed my public key (e, n=pq) and my private key (d).

Now, I was careless and compromised my private key (d). p and q were not leaked. Taking into account that (e, n) were already public knowledge, would it be safe to generate a new key pair with the same p and q or are they somehow compromised by the leaking of the private key?

If it would not be safe, how could someone compute p and q from my public-private key pair?

• In practice almost everything in this century uses PKCS1 privatekey format which stores p,q explicitly as well as d-mod-pm1, d-mod-qm1, qinv-mod-p for CRT, so they're already compromised. But that's an answer for security.SX not crypto.SX. – dave_thompson_085 Nov 27 '19 at 5:04

There are several methods to compute $$p$$ and $$q$$ from $$n$$, $$e$$ and $$d$$. See appendix C of this document.