7.NumberTheory
7.NumberTheory
Raj Jain
Washington University in Saint Louis
Saint Louis, MO 63130
[email protected]
Audio/Video recordings of this lecture are available at:
http://www.cse.wustl.edu/~jain/cse571-14/
Washington University in St. Louis CSE571S ©2014 Raj Jain
8-1
Overview
1. Prime numbers
2. Fermat’s and Euler’s Theorems
3. Testing for primality
4. The Chinese Remainder Theorm
5. Discrete Logarithms
These slides are partly based on Lawrie Brown’s slides supplied with William Stallings’s
book “Cryptography and Network Security: Principles and Practice,” 6th Ed, 2013.
Washington University in St. Louis CSE571S ©2014 Raj Jain
8-2
Fermat's Little Theorem
Given a prime number p:
ap-1 = 1 (mod p)
For all integers a≠p
Or
ap = a (mod p)
Example:
14 mod 5=1
24 mod 5=1
34 mod 5=1
44 mod 5=1
Inconclusive
3. if aq mod n = 1 then return Y
(aq)2 mod n = n-1?
(“inconclusive");
4. for j = 0 to k – 1 do
j Y
5. if (a2 q mod n = n-1) (aq)4 mod n = n-1?
then return(“inconclusive")
6. return (“composite")
If inconclusive after t tests with
different a’s: k−1
Y
Probability (n is Prime after t tests)
(aq )2 mod n = n-1?
= 1- 4-t
E.g., for t=10 this probability is > Composite
0.99999
Washington University in St. Louis CSE571S ©2014 Raj Jain
8-6
Miller Rabin Algorithm Example
Test 29 for primality
29-1 = 28 = 227 = 2kq k=2, q=7
Let a = 10
10 mod 29 = 17
7
17 mod 29 = 28 Inconclusive
2
Let a=5
5
55 mod 221 =112
k
÷ ¸−1 !
X M M
x= ai mod mi
mi mi
i=1