Miller Rabin Proof

number theoryprime numbers

In Miller Rabin test, let n – 1 = 2xs, then,
if as mod n = 1 or as mod n = -1 then we say n is probably prime or if a2xs mod n = 1 then also we say n is probably prime but,
How can we say surely that n is composite if a2xs mod n = 1.
I read the proof here and understood the case where we say n is probably prime but I'm a little confused about the case where a2xs mod n = 1.
If anyone could explain that would be quite helpful.

Best Answer

If you start with $a^{s 2^N} \equiv 1 \bmod n, a^s \not \equiv 1 \bmod n$ then by repeated squaring, at some point you'll obtain $x = a^{2^ms}, x \not \equiv 1 \bmod n, x^2 \equiv 1 \bmod n$, if $n$ is prime this implies $x \equiv -1 \bmod n$

(because for $n=p$ prime the polynomial $x^2-1$ has only two roots in the field $\Bbb{Z/p Z}$)

Related Question