dissertacao.pdf
dissertacao.pdf
dissertacao.pdf
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
2 Primality Tests and Factorization Algorithms<br />
2.1 Primality Tests<br />
Primality tests are algorithms that receive as input a positive integer N and<br />
output some statement about its primality. In the best scenario, they guarantee<br />
that either N is prime or that N is composite. Such tests are called determinis-<br />
tic. Other tests either guarantee that N is composite, or that N is prime with<br />
a certain probability. These tests are called probabilistic.<br />
The most obvious primality test for an integer N, known for thousands<br />
of years, consists in simple trial division by all integers up to √ N, since any<br />
composite number must have a divisor p that satisfies p ≤ √ N. If a factor<br />
is found, we know that the number is composite, otherwise we prove that N<br />
is prime. This deterministic algorithm has efficiency O( √ N) and therefore is<br />
extremely inefficient for large integers, say with 1024 bits like often used in RSA.<br />
The probabilistic primality tests we will explain, most of them, simply aim<br />
to prove that N is a composite number. If they do not prove it, then there is a<br />
chance that they are prime. Repeating this test with different parameters will<br />
lead to a bigger certainty that we are in the presence of a prime number.<br />
2.1.1 Fermat’s Primality Test<br />
The first primality test presented in this section derives from a theorem discov-<br />
ered by Fermat in 1640. The proof is due to Leibniz, who found it 40 years<br />
later. It states the following:<br />
Theorem 7. For any prime number p and for any integer a such that 0 < a < p,<br />
we have:<br />
a (p−1) ≡ 1 (mod p) (24)<br />
Proof. a, 2a, 3a, ..., (p − 1)a are all distinct mod p, therefore each of them is<br />
congruent to one of 1, 2, 3, ..., p − 1. Because congruences preserve multiplicity,<br />
we have:<br />
a2a3a...(p − 1)a ∼ = 1 ∗ 2 ∗ 3 ∗ ... ∗ (p − 1) (mod p) ⇔ (25)<br />
(p − 1)!a p−1 ∼ = (p − 1)! (mod p) (26)<br />
Diving both sides by (p − 1)! we get the equality.<br />
21