Pollard-Rho( n )
- i <-- 1
- x1 <-- Random( 0, n-1 )
- y <-- x1
- k <-- 2
- while True
- do i <-- i + 1
- xi <--
xi-12 - 1 mod n
- d <-- GCD( y -
xi, n )
- if d
!= 1 AND d != n
-
then Print d
- if
i = k
-
then y <-- xi
- k <-- 2k
Fermat's Little Theorem: If p is prime and a is not a multiple of p,
then ap-1 = 1 mod p
A composite number n that satisfies
an-1 = 1 mod n is called a
base-a pseudoprime.
For example: 341, 561, 645, 1105
Carmichael numbers are pseudoprime to all bases
For example: 561, 1105, 1729
Miller-Rabin( n, s )
- for j <-- 1 to s
- do a <-- Random( 1, n-1 )
- if Witness( a, n )
- then
return Composite
- return Prime
Witness( a, n )
- factor n - 1 as 2t * u where u is odd (possibly composite)
- x0 <-- au mod n
- for i <-- 1 to t
- do xi <--
xi-12 mod n
- if
xi = 1 AND xi-1 != 1 AND
xi-1 != n-1
-
then return True
- if xt != 1
- then return True
- return False
References:
Applied Cryptography,
by Bruce Schneier,
Wiley, 1996
Introduction to Algorithms, second edition
by Cormen, Leiserson, Rivest, and Stein
MIT Press/McGraw-Hill, 2001