Definition (Miller-Rabin Primality Testing)
Suppose is a positive odd integer and write for some positive integer and an odd number . Suppose is an integer between and . If is prime, then one of the following congruence relations most hold true:
If is not a strong probable prime to base , then is called a witness for the compositeness of , or a Miller-Rabin witness for .
If , it is a prime. Otherwise, if is even, output not a prime. Otherwise, we repeat for total random bases for . If we end without showing that is a witness, then is a prime.
If the number of times this is repeated is , the probability of being a prime is .
Example 1
Check that is a strong probable prime to the base .
- .
- So, .
- Now, we check for , so .
- Then, calculate
- This is not or . Both fail.
- Check
This is true. This is a strong probable prime.
Example 2
Check that is a witness for .
- .
- Then
- Check , and
- Then, calculate
- . Both conditions fail.
- .
- Since both fail, is a witness for ‘s composite.