DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9...
Transcript of DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9...
![Page 1: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/1.jpg)
DTTF/NB479: Dszquphsbqiz Day 9
Announcements: Homework 2 due now Computer quiz Thursday on chapter 2
Questions? Today: Wrap up congruences Fermat’s little theorem Euler’s theorem Both really important for RSA – pay careful attention!
![Page 2: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/2.jpg)
The Chinese Remainder Theorem establishes an equivalence
A single congruence mod a composite number is equivalent to a system of congruences mod its factors Two-factor form Given gcd(m,n)=1. For integers a and b, there exists
exactly 1 solution (mod mn) to the system:
)(mod)(mod
nbxmax
≡≡
![Page 3: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/3.jpg)
CRT Equivalences let us use systems of congruences to solve problems
Solve the system:
How many solutions? Find them.
)15(mod5)7(mod3
≡≡
xx
)35(mod12 ≡x
![Page 4: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/4.jpg)
Chinese Remainder Theorem
n-factor form Let m1, m2,… mk be integers such that gcd(mi, mj)=1
when i ≠ j. For integers a1, … ak, there exists exactly 1 solution (mod m1m2…mk) to the system:
)(mod...
)(mod)(mod
22
11
kk max
maxmax
≡
≡≡
![Page 5: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/5.jpg)
Modular Exponentiation is extremely efficient since the partial results are always small
Compute the last digit of 32000
Compute 32000 (mod 19) Idea: Get the powers of 3 by repeatedly squaring 3, BUT
taking mod at each step.
Q
![Page 6: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/6.jpg)
Modular Exponentiation Technique and Example
Compute 32000 (mod 19) Technique: Repeatedly square
3, but take mod at each step.
Then multiply the terms you need to get the desired power.
Book’s powermod()
1736353
92561631643
4289173)2(173663
6255358193
93
1024
512
256
2128
264
232
216
28
24
2
≡
≡
≡
≡≡≡
≡=
≡≡=
−≡≡=
≡≡=
≡≡=
≡
or
)19(mod93)1248480(3
)17)(16)(9)(5)(6)(17(3)3)(3)(3)(3)(3)(3(3
2000
2000
2000
166412825651210242000
≡
≡
≡
≡
(All congruences are mod 19)
![Page 7: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/7.jpg)
Modular Exponentiation Example
Compute 32000 (mod 152)
17325381393
7318769137313728917317625253256561813
819393
1024
512
256
128
264
232
216
28
24
2
≡
≡
≡
≡
≡≡=
≡≡=
≡≡=
≡≡=
≡=
≡
)152(mod93)384492875(3
)17)(73)(9)(81)(25)(17(3)3)(3)(3)(3)(3)(3(3
2000
2000
2000
166412825651210242000
≡
≡
≡
≡
![Page 8: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/8.jpg)
Fermat’s Little Theorem: If p is prime and gcd(a,p)=1, then a(p-1)≡1(mod p)
8
1-2
![Page 9: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/9.jpg)
Fermat’s Little Theorem: If p is prime and gcd(a,p)=1, then a(p-1)≡1(mod p)
Examples: 22=1(mod 3) 64 =1(mod ???) (32000)(mod 19)
9
1 2 3 4 5 6
S= f(1)=2 f(2)=4 f(3)=6 f(4)=1 f(5)=3 f(6)=5
Example: a=2, p=7
1-2
![Page 10: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/10.jpg)
The converse when a=2 usually holds
Fermat: If p is prime and doesn’t divide a, Converse: If , then p is prime and doesn’t divide a. This is almost always true when a = 2. Rare counterexamples: n = 561 =3*11*17, but
n = 1729 = 7*13*19 Can do first one by hand if use Fermat and combine results with
Chinese Remainder Theorem
)(mod11 pa p ≡−
)(mod11 pa p ≡−
)561(mod12560 ≡
![Page 11: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/11.jpg)
Primality testing schemes typically use the contrapositive of Fermat
Even?
div by other small primes?
Prime by Factoring/ advanced techn.?
n
no
no
yes
prime
![Page 12: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/12.jpg)
Primality testing schemes typically use the contrapositive of Fermat
Use Fermat as a filter since it’s faster than factoring (if calculated using the powermod method). 1)(mod2
?1 ≡− nn
Even?
div by other small primes?
Prime by Factoring/ advanced techn.?
n
no
no
yes
yes
prime
Fermat: p prime 2p-1 ≡ 1 (mod p) Contrapositive?
Why can’t we just compute 2n-1(mod n) using Fermat if it’s so much faster?
)(mod12?
1 nn ≡−
3
![Page 13: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/13.jpg)
Euler’s Theorem is like Fermat’s, but for composite moduli
If gcd(a,n)=1, then So what’s φ(n)?
13
)(mod1)( na n ≡φ
4
![Page 14: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/14.jpg)
φ(n) is the number of integers a, such that 1 ≤ a ≤ n and gcd(a,n) = 1.
Examples: 1. φ(10) = 4.
2. When p is prime, φ(p) = ____
3. When n =pq (product of 2 primes), φ(n) = ____
14
5
![Page 15: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/15.jpg)
The general formula for φ(n)
Example: φ(12)=4
[Bill Waite, RHIT 2007]
∏
−=
np ppnn
|
1)(φ
6
p are distinct primes
![Page 16: DTTF/NB479: Dszquphsbqiz Day 9 Announcements · 2013-03-16 · DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Computer quiz Thursday on chapter 2 Questions? Today:](https://reader034.fdocuments.us/reader034/viewer/2022050511/5f9ba4901be93074705b09ca/html5/thumbnails/16.jpg)
Euler’s Theorem can also lead to computations that are more efficient than modular exponentiation
as long as gcd(a,n) = 1
Examples: 1. Find last 3 digits of 7803
2. Find 32007 (mod 12) 3. Find 26004 (mod 99) 4. Find 26004 (mod 101)
Basic Principle: when working mod n, view the exponents mod φ(n).
)(mod1)( na n ≡φ
7-10