Download Primality Tests (2pp.)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Primality Tests
Definition: A primality test is a criterion for a number n not to be prime.
Thus: n “fails” the test ⇒ n is definitely composite,
n “passes” the test ⇒ n may be prime,
n “passes” many tests ⇒ n is very likely prime.
Test 0: Naive Method
√
– test for some/all m ≤ n whether m6 | n.
Test 1: Fermat Test
– test for b < n whether n satisfies
(1)
bn−1 ≡ 1 (mod n),
i.e. whether n is a pseudoprime to the base b.
– existence of Carmichael numbers ⇒ not practical
Test 2: Euler Test (Solovay-Strassen Method)
– test for b < n with (b, n) = 1 whether n satisfies
b
(n−1)/2
(2)
b
≡
(mod n),
n
⇒ n is an Euler pseudoprime to the base b.
Note: n passes k tests ⇒ Prob(n is composite) ≤ 1k .
2
2
Test 3: Miller-Rabin Test
– write n − 1 = 2αs, where s is odd;
– for b < n with (b, n) = 1, test whether
(3)
bs ≡ 1 (mod n) or
rs
2
(4) b
≡ −1 (mod n) for some 0 ≤ r < α
⇒ n is a strong pseudoprime to the base b.
Notes: 1) If n ≡ 3 (mod 4), then Test 3 = Test 2.
2) n passes k tests ⇒ Prob(n is composite) ≤ 1k .
4
3) By using (GRH), one can show:
n composite ⇒ ∃b < 2(log n)2 such that
n fails Test 3 for b.
Notation: Given a number n, let
Pn = {b (mod n) : (1) holds}
En = {b (mod n) : (2) holds and (b, n) = 1}
Sn = {b (mod n) : (3) and (4) hold}
Then we have
Sn ⊂ En ≤ Pn ≤ (Z/nZ)×.
Moreover, if n is composite, then
#Sn
1
#En
#En 1
≤ , whereas
≤
≤ .
n−1 4
n − 1 φ(n) 2