Why using primes as base in the Rabin-Miller test?

624 Views Asked by At

I have done some computer tests with the Rabin-Miller primality test:

To test an odd number $n$, write $n=2^r\cdot s + 1$, where $s$ is odd. Given a number $a$ such that $1<a<n-1$,
if
$\:\:\:\:1$. $a^s\equiv 1\pmod n$
$\:\:\:\:\:\:\:\:\:\:\:\:$or
$\:\:\:\:2$. it exists an integer $j: 0\le j<r$ with $a^{2^j\cdot s}\equiv -1\pmod n$
then $n$ is pseudo prime.

It seems to be popular to chose $a$ to be a prime number, and my question is if there are rational reasons for that?

I have computed the number of primality tests until $10$ errors appears for randomly selected b-digit $n$ and for $a=2$, for random $a$ in the intervall $1<a<n-1$ and finally for random primes in the same intervall and the result differs very little regarding the equation for the line. Below the test for random primes as $a$: enter image description here The x-axis is the number of bits for $n$ and the y-axis is the logarithm of the average number of tests until an error occurred.