Professional Documents
Culture Documents
Crypto 7
Crypto 7
Cryptography 7 Primes
Generation of Primes
Factorization
Chinese Remainder
Theorem (CRT)
Chittaranjan Pradhan
School of Computer Engineering,
KIIT University
7.1
Primes, Primality Test,
Primes Factorization & CRT
Chittaranjan Pradhan
Primes
• Check whether the number n is divisible by the primes less Chinese Remainder
√ Theorem (CRT)
than n
• Ex: 97 is prime? 301 is prime?
1. Sieve of Eratosthenes
• Φ(10), Φ(13)
• What is the number of elements in Z14 ∗
7.3
Primes, Primality Test,
Primes... Factorization & CRT
Chittaranjan Pradhan
Fermat’s Little Theorem
ap ≡ a mod p Factorization
Chinese Remainder
Theorem (CRT)
• If the exponent and the modulus are not the same, with
substitution this can be solved
• Ex: 610 mod 11, 312 mod 11
Application of Fermat’s Little Theorem:
• Used to find multiplicative inverses quickly if the modulus
is a prime
• If p is a prime and a is an integer such that p doesn’t
divide a, then
a−1 mod p = ap−2 mod p
• Ex: 8−1 mod 17, 5−1 mod 23
7.4
Primes, Primality Test,
Primes... Factorization & CRT
Chittaranjan Pradhan
Factorization
• If a & n are coprimes, aΦ(n) ≡ 1 (mod n) Chinese Remainder
Theorem (CRT)
• If a & n are not coprimes and if n = p x q,
ak ∗Φ(n)+1 ≡ a (mod n)
7.5
Primes, Primality Test,
Generation of Primes Factorization & CRT
Chittaranjan Pradhan
Primes
Generation of Primes
Generation of Primes Primality Testing
Deterministic algorithms
Mp = 2p - 1 Factorization
Chinese Remainder
Theorem (CRT)
Ex: p= 2, 3, 5, 7, 11
• Fermat Primes
n
Fn = 22 +1
Ex: n=1, 2, 3, 4, 5
7.6
Primes, Primality Test,
Primality Testing Factorization & CRT
Chittaranjan Pradhan
Primes
Generation of Primes
Primality Testing
Deterministic algorithms
Probabilistic algorithms
Recommended Primality
Primality Testing Test
Factorization
7.7
Primes, Primality Test,
Deterministic algorithms Factorization & CRT
Chittaranjan Pradhan
Divisibility Algorithm
√ Primes
• All divisors smaller than n are used. If any of these Generation of Primes
Factorization
Chinese Remainder
Theorem (CRT)
Primes
Divisibility Algorithm... Generation of Primes
Primality Testing
• It can be further improved by using a table of primes Deterministic algorithms
√ Probabilistic algorithms
between 2 & n Recommended Primality
Test
Factorization
• Ex: nb = 200bits
7.9
Primes, Primality Test,
Deterministic algorithms... Factorization & CRT
Chittaranjan Pradhan
AKS (Agrawal - Kayal - Saxena) Algorithm
Factorization
Chinese Remainder
Theorem (CRT)
7.10
Primes, Primality Test,
Probabilistic algorithms Factorization & CRT
Chittaranjan Pradhan
Primality Testing
• If p is a prime, then ap−1 ≡ 1 mod p Deterministic algorithms
Probabilistic algorithms
• Bit-operation complexity O(nb ) Recommended Primality
Test
Factorization
• Ex: 7, 8, 17, 22
7.11
Primes, Primality Test,
Probabilistic algorithms... Factorization & CRT
Chittaranjan Pradhan
Primes
3. Miller - Rabin Test Generation of Primes
Primality Testing
• Combines the Fermat test and Square root test Deterministic algorithms
Probabilistic algorithms
power of 2 Factorization
7.12
Primes, Primality Test,
Probabilistic algorithms... Factorization & CRT
Chittaranjan Pradhan
Primality Testing
Deterministic algorithms
Probabilistic algorithms
Recommended Primality
Test
Factorization
Chinese Remainder
Theorem (CRT)
7.13
Primes, Primality Test,
Recommended Primality Test Factorization & CRT
Chittaranjan Pradhan
Ex: 4033
7.14
Primes, Primality Test,
Factorization Factorization & CRT
Chittaranjan Pradhan
Factorization Primes
Generation of Primes
n = p1 e1 x p2 e2 x ... x pk ek
Deterministic algorithms
Probabilistic algorithms
Recommended Primality
Test
7.15
Primes, Primality Test,
Factorization... Factorization & CRT
Chittaranjan Pradhan
1. Trial Division Method
√
• Trial division can be attempted by all primes up to n Primes
Generation of Primes
• This method is good if n < 210 , but it is inefficient and Primality Testing
Factorization
Chinese Remainder
Theorem (CRT)
7.16
Primes, Primality Test,
Factorization... Factorization & CRT
Chittaranjan Pradhan
2. Fermat Method
Factorization
Chinese Remainder
Theorem (CRT)
7.17
Primes, Primality Test,
Factorization... Factorization & CRT
Chittaranjan Pradhan
3. Pollard’s p-1 Method
7.18
Primes, Primality Test,
Factorization... Factorization & CRT
Chittaranjan Pradhan
4. Pollard rho Method
7.19
Primes, Primality Test,
Chinese Remainder Theorem (CRT) Factorization & CRT
Chittaranjan Pradhan
Chinese Remainder Theorem (CRT)
with one variable but different moduli, which are relatively Primality Testing
x ≡ a2 (mod m2 ) Factorization
Primes
Generation of Primes
Primality Testing
Deterministic algorithms
• x ≡ 2 mod 3 Factorization
7.21