next up previous
Next: When  and  Are Close Up: Lecture 10: Attacking RSA Previous: Lecture 10: Attacking RSA


Factoring $ n$ Given $ \varphi (n)$



If you know $ \varphi (n)$ then it is easy to factor $ n$:
Suppose $ n=pq$. Given $ \varphi (n)$, it is very easy to compute $ p$ and $ q$. We have

$\displaystyle \varphi (n) = (p-1)(q-1) = pq-(p+q)+1,
$

so we know both $ pq=n$ and $ p+q = n+1 - \varphi (n)$. Thus we know the polynomial

$\displaystyle x^2 - (p+q)x + pq = (x-p)(x-q)
$

whose roots are $ p$ and $ q$. These roots can be found using the quadratic formula.

Example 1.1  

? n=nextprime(random(10^10))*nextprime(random(10^10));
? phin=eulerphi(n);
? f = x^2 - (n+1-phin)*x + n
%6 = x^2 - 12422732288*x + 31615577110997599711
? polroots(f)
%7 = [3572144239, 8850588049]
? n
%8 = 31615577110997599711
? 3572144239*8850588049
%9 = 31615577110997599711



William A Stein 2001-10-04