Considering the condition of Rabin-Miller's prime recognition, should the case $r = 1$ also be tested?

44 Views Asked by At

In my textbook for cryptography the lemma for this prime recognition is stated as following:

_Let $n \in \mathbb N$, $n = 2^sd + 1$, $d$ is odd. Denote, for $1 \leq x \lt n$, by $C(x)$ the condition:

$\quad$ $\quad$ $\quad$ $x^d \not\equiv 1 \pmod n$ and ${x}^{2^rd} \not\equiv -1 \pmod n$ for all $1 \lt r \lt s$.

If $C(x)$ holds for some $1 \leq x \leq n$, then $n$ is not a prime. If $n$ is not a prime, then $C(x)$ holds for at least half of $x$ between $1$ and $n$.

But from what I have seen on Wikipedia, the case where r = 1 should be tested. And in this post, in the answer, the case r = 1 is also included. Therefore, in the condition it should be "for all 1 $\leq$ r $\lt$ s", shouldn't it?

1

There are 1 best solutions below

0
On BEST ANSWER

Consider $n=5$. Then the $C(x)$ from your textbook translates into $x\not\equiv 1\pmod{n}$, obviously wrong. With $r=1$ (but not $r=0$) included, an additional requirement is $x^2\not\equiv-1$, satisfied by $x=4$ and claiming $5$ "not a prime" again.

The correct condition is "for $0\leqslant r<s$".