-1
$\begingroup$

Given integers $N$ (modulus), $e$ (public exponent), and $d$ (private exponent), how would I find the primes $p$ and $q$ that compose $N$? I'm trying to do this in Python. This is homework.

$\endgroup$
1

1 Answer 1

0
$\begingroup$

If you want to recover the primes $p,q$ from $(N,e,d),$ note that $L = ed - 1$ is a multiple of the Carmichael function $\lambda(N).$

Assuming your data is from a valid RSA setting, then $N$ is odd and square-free and there is a probabilistic algorithm to compute $p,q$ from $N,L\;$ see e.g. the solutions for J. v. zur Gathen, J. Gerhard, Modern computer algebra, 2nd ed., 2003: Algorithm 18.16 (Special integer factorization) in https://cosec.bit.uni-bonn.de/fileadmin/user_upload/science/mca/solutions.pdf.

BTW: You can't factor primes (or the factorization is trivial).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.