February 26, 2002
Practical Aspects of Modern Cryptography
50
The Miller-Rabin Primality Test
nTo test an integer N for primality, write N-1 as N-1 = m2k where m is odd.
nRepeat several (many) times
nSelect a random a in 1 < a < N-1
nCompute am, a2m, a4m, …, a(N-1)/2 all mod N.
nIf am = ±1 or if some a2im = -1, then N is probably prime – continue.
nOtherwise, N is composite – stop.