+ All Categories
Home > Documents > DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz...

DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz...

Date post: 22-Dec-2015
Category:
View: 219 times
Download: 5 times
Share this document with a friend
Popular Tags:
16
DTTF/NB479: Dszquphsbqiz DTTF/NB479: Dszquphsbqiz Day 9 Day 9 Announcements: Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter 2 Questions? Questions? Today: Today: Wrap up congruences Wrap up congruences Fermat’s little theorem Fermat’s little theorem Euler’s theorem Euler’s theorem Both really important for RSA – pay Both really important for RSA – pay careful attention! careful attention!
Transcript
Page 1: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

DTTF/NB479: DszquphsbqizDTTF/NB479: Dszquphsbqiz Day 9 Day 9

Announcements:Announcements: Homework 2 due nowHomework 2 due now Computer quiz Thursday on chapter 2Computer quiz Thursday on chapter 2

Questions?Questions?

Today: Today: Wrap up congruencesWrap up congruences Fermat’s little theoremFermat’s little theorem Euler’s theoremEuler’s theorem Both really important for RSA – pay careful attention!Both really important for RSA – pay careful attention!

Page 2: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

The Chinese Remainder Theorem establishes an The Chinese Remainder Theorem establishes an equivalenceequivalence

A single congruence mod a A single congruence mod a composite number composite number is equivalent to a system of congruences mod is equivalent to a system of congruences mod its factorsits factors

Two-factor formTwo-factor form Given gcd(m,n)=1. For integers a and b, there exists Given gcd(m,n)=1. For integers a and b, there exists

exactly 1exactly 1 solution (mod mn) to the system: solution (mod mn) to the system:

)(mod

)(mod

nbx

max

Page 3: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

CRT Equivalences let us use systems of CRT Equivalences let us use systems of congruences to solve problemscongruences to solve problems

Solve the system:Solve the system:

How many solutions?How many solutions? Find them.Find them.

)15(mod5

)7(mod3

x

x

)35(mod12 x

Q

Page 4: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Chinese Remainder TheoremChinese Remainder Theorem

n-factor formn-factor form Let mLet m11, m, m22,… m,… mkk be integers such that gcd(m be integers such that gcd(mii, m, mjj)=1 )=1

when i ≠ j. For integers awhen i ≠ j. For integers a11, … a, … akk, there exists , there exists exactly exactly

11 solution (mod m solution (mod m11mm22…m…mkk) to the system:) to the system:

)(mod

...

)(mod

)(mod

22

11

kk max

max

max

Page 5: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Modular Exponentiation is extremely efficient since Modular Exponentiation is extremely efficient since the partial results are always smallthe partial results are always small

Compute the last digit of 3Compute the last digit of 320002000

Compute 3Compute 320002000 (mod 19) (mod 19) Idea:Idea:Get the powers of 3 by repeatedly squaring 3, BUT Get the powers of 3 by repeatedly squaring 3, BUT taking mod at each step.taking mod at each step.

Q

Page 6: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Modular Exponentiation Technique and ExampleModular Exponentiation Technique and Example

Compute 3Compute 320002000 (mod 19)(mod 19)

Technique:Technique: Repeatedly square Repeatedly square

3, but take mod 3, but take mod at at each stepeach step..

Then multiply the Then multiply the terms you need to terms you need to get the desired get the desired power.power.

Book’s Book’s powermod()powermod()

173

63

53

9256163

1643

4289173

)2(173663

62553

58193

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: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Modular Exponentiation ExampleModular Exponentiation Example

Compute 3Compute 320002000 (mod (mod 152152))

173

253

813

93

73187691373

137289173

17625253

256561813

8193

93

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: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Fermat’s Little Theorem:Fermat’s Little Theorem:If p is prime and gcd(a,p)=1, then aIf p is prime and gcd(a,p)=1, then a (p-1)(p-1)≡1(mod p)≡1(mod p)

8

1-2

Page 9: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Fermat’s Little Theorem:Fermat’s Little Theorem:If p is prime and gcd(a,p)=1, then aIf p is prime and gcd(a,p)=1, then a (p-1)(p-1)≡1(mod p)≡1(mod p)

Examples: Examples: 2222=1(mod 3)=1(mod 3) 664 4 =1(mod ???)=1(mod ???) (3(320002000)(mod 19))(mod 19)

9

123456

S= f(1)=2f(2)=4f(3)=6f(4)=1f(5)=3f(6)=5

Example: a=2, p=7

1-2

Page 10: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

The converse when a=2 usually holds The converse when a=2 usually holds

Fermat: Fermat: If p is prime and doesn’t divide a,If p is prime and doesn’t divide a,

Converse: Converse: IfIf , then p is prime and doesn’t divide a. , then p is prime and doesn’t divide a.

This isThis is almost almost always true when a = 2. Rare counterexamples: always true when a = 2. Rare counterexamples: n = 561 =3*11*17, butn = 561 =3*11*17, but

n = 1729 = 7*13*19n = 1729 = 7*13*19 Can do first one by hand if use Fermat and combine results with Chinese Can do first one by hand if use Fermat and combine results with Chinese

Remainder TheoremRemainder Theorem

)(mod11 pa p

)(mod11 pa p

)561(mod12560

Page 11: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Primality testing schemes typically use the Primality testing schemes typically use the contrapositive of Fermatcontrapositive 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: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Primality testing schemes typically use the Primality testing schemes typically use the contrapositive of Fermatcontrapositive of Fermat

Use Fermat as a filter since it’s Use Fermat as a filter since it’s faster than factoring (if faster than factoring (if calculated using the powermod calculated using the powermod method).method).

1)(mod2?

1 nn

Even?

div by other small primes?

Prime by Factoring/advanced techn.?

n

no

no

yes

yes

prime

Fermat: p primeFermat: p prime 2 2p-1p-1 ≡ 1 (mod p) ≡ 1 (mod p)Contrapositive?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: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Euler’s Theorem is like Fermat’s, but for composite Euler’s Theorem is like Fermat’s, but for composite modulimoduli

If gcd(a,n)=1, thenIf gcd(a,n)=1, then

So what’s So what’s (n)?(n)?

13

)(mod1)( na n

4

Page 14: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

(n) is the number of integers a, (n) is the number of integers a, such that 1 ≤ a ≤ n and gcd(a,n) = 1.such that 1 ≤ a ≤ n and gcd(a,n) = 1.

Examples: Examples: 1.1. (10) = 4.(10) = 4.

2.2. When p is prime, When p is prime, (p) = ____(p) = ____

3.3. When n =pq (product of 2 primes), When n =pq (product of 2 primes), (n) = ____(n) = ____

14

5

Page 15: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

The general formula for The general formula for (n)(n)

Example: Example: 11

[Bill Waite, RHIT 2007]

np p

pnn

|

1)(

6

p are distinct primes

Page 16: DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.

Euler’s Theorem can also lead to computations Euler’s Theorem can also lead to computations that are more efficient than modular exponentiationthat are more efficient than modular exponentiation

as long as gcd(a,n) = 1as long as gcd(a,n) = 1

Examples:Examples:1.1. Find last 3 digits of 7Find last 3 digits of 7803803

2.2. Find 3Find 320072007 (mod 12) (mod 12)

3.3. Find 2Find 260046004 (mod 99) (mod 99)

4.4. Find 2Find 260046004 (mod 101) (mod 101)

BasicBasicPrinciple: when working mod n, view the exponents mod Principle: when working mod n, view the exponents mod (n).(n).

)(mod1)( na n

7-10


Recommended