SlideShare a Scribd company logo
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!
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
n
b
x
m
a
x


CRT Equivalences let us use systems of
congruences to solve problems
Solve the system:
How many solutions?
 Find them.
)
15
(mod
5
)
7
(mod
3


x
x
)
35
(mod
1
2

x
Q
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
2
2
1
1
k
k m
a
x
m
a
x
m
a
x



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
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()
17
3
6
3
5
3
9
256
16
3
16
4
3
4
289
17
3
)
2
(
17
36
6
3
6
25
5
3
5
81
9
3
9
3
1024
512
256
2
128
2
64
2
32
2
16
2
8
2
4
2






















or
)
19
(mod
9
3
)
1248480
(
3
)
17
)(
16
)(
9
)(
5
)(
6
)(
17
(
3
)
3
)(
3
)(
3
)(
3
)(
3
)(
3
(
3
2000
2000
2000
16
64
128
256
512
1024
2000




(All congruences are mod 19)
Modular Exponentiation Example
Compute 32000
(mod 152)
17
3
25
3
81
3
9
3
73
18769
137
3
137
289
17
3
17
625
25
3
25
6561
81
3
81
9
3
9
3
1024
512
256
128
2
64
2
32
2
16
2
8
2
4
2



















)
152
(mod
9
3
)
384492875
(
3
)
17
)(
73
)(
9
)(
81
)(
25
)(
17
(
3
)
3
)(
3
)(
3
)(
3
)(
3
)(
3
(
3
2000
2000
2000
16
64
128
256
512
1024
2000




Fermat’s Little Theorem:
If p is prime and gcd(a,p)=1, then a(p-1)≡1(mod p)
8
1-2
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
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
)
(mod
1
1
p
ap


)
(mod
1
1
p
ap


)
561
(mod
1
2560

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
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
)
(mod
2
?
1


n
n
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?
)
(mod
1
2
?
1
n
n


3
Euler’s Theorem is like Fermat’s, but for composite
moduli
If gcd(a,n)=1, then
So what’s f(n)?
13
)
(mod
1
)
(
n
a n

f
4
f(n) is the number of integers a,
such that 1 ≤ a ≤ n and gcd(a,n) = 1.
Examples:
1. f(10) = 4.
2. When p is prime, f(p) = ____
3. When n =pq (product of 2 primes), f(n) = ____
14
5
The general formula for f(n)
Example: f(12)4
[Bill Waite, RHIT 2007]
 






 

n
p p
p
n
n
|
1
)
(
f
6
p are distinct primes
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 f(n).
)
(mod
1
)
(
n
a n

f
7-10

More Related Content

PPT
Chapter 8 Cryptography in ntwrokr standarsdppt
PPT
ch08 modified.pptmodified.pptmodified.ppt
PPT
Crptography and network security Number theory -
PPT
PPT
2010 3-24 cryptography stamatiou
PPTX
Introduction to the AKS Primality Test
PPT
Chapter 8 Cryptography in ntwrokr standarsdppt
ch08 modified.pptmodified.pptmodified.ppt
Crptography and network security Number theory -
2010 3-24 cryptography stamatiou
Introduction to the AKS Primality Test

Similar to 09-FermatEuler.ppt (20)

PPT
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
PPT
EULER AND FERMAT THEOREM
PPT
ch08_cryptography_notes_by_william_stallings
PPTX
Information and network security 34 primality
PPTX
The Complexity Of Primality Testing
PDF
modul pembelajaran 4
PPTX
Nbvtalkatbzaonencryptionpuzzles
PPTX
Nbvtalkatbzaonencryptionpuzzles
PDF
Number theory
PPTX
Basics of Mathematical Cryptography
PPT
Information Security Seminar #2
PPTX
ppt-number-theory-fermats-theorem_(2).pptx
PPT
Iss lecture 3
PPTX
FermatThm.pptx
PPTX
Number theory and cryptography
PDF
Number Theory for Security
PDF
Number theory
PPT
wilson's and fermat little theorem .ppt
DOCX
Cryptography and Network Security Principles and Practice.docx
PPT
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
EULER AND FERMAT THEOREM
ch08_cryptography_notes_by_william_stallings
Information and network security 34 primality
The Complexity Of Primality Testing
modul pembelajaran 4
Nbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
Number theory
Basics of Mathematical Cryptography
Information Security Seminar #2
ppt-number-theory-fermats-theorem_(2).pptx
Iss lecture 3
FermatThm.pptx
Number theory and cryptography
Number Theory for Security
Number theory
wilson's and fermat little theorem .ppt
Cryptography and Network Security Principles and Practice.docx
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
Ad

Recently uploaded (20)

PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PPT
Occupational Health and Safety Management System
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
737-MAX_SRG.pdf student reference guides
PDF
PPT on Performance Review to get promotions
Exploratory_Data_Analysis_Fundamentals.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Fundamentals of Mechanical Engineering.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Fundamentals of safety and accident prevention -final (1).pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
Occupational Health and Safety Management System
Information Storage and Retrieval Techniques Unit III
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
III.4.1.2_The_Space_Environment.p pdffdf
Visual Aids for Exploratory Data Analysis.pdf
737-MAX_SRG.pdf student reference guides
PPT on Performance Review to get promotions
Ad

09-FermatEuler.ppt

  • 1. 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!
  • 2. 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 n b x m a x  
  • 3. CRT Equivalences let us use systems of congruences to solve problems Solve the system: How many solutions?  Find them. ) 15 (mod 5 ) 7 (mod 3   x x ) 35 (mod 1 2  x Q
  • 4. 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 2 2 1 1 k k m a x m a x m a x   
  • 5. 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
  • 6. 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() 17 3 6 3 5 3 9 256 16 3 16 4 3 4 289 17 3 ) 2 ( 17 36 6 3 6 25 5 3 5 81 9 3 9 3 1024 512 256 2 128 2 64 2 32 2 16 2 8 2 4 2                       or ) 19 (mod 9 3 ) 1248480 ( 3 ) 17 )( 16 )( 9 )( 5 )( 6 )( 17 ( 3 ) 3 )( 3 )( 3 )( 3 )( 3 )( 3 ( 3 2000 2000 2000 16 64 128 256 512 1024 2000     (All congruences are mod 19)
  • 7. Modular Exponentiation Example Compute 32000 (mod 152) 17 3 25 3 81 3 9 3 73 18769 137 3 137 289 17 3 17 625 25 3 25 6561 81 3 81 9 3 9 3 1024 512 256 128 2 64 2 32 2 16 2 8 2 4 2                    ) 152 (mod 9 3 ) 384492875 ( 3 ) 17 )( 73 )( 9 )( 81 )( 25 )( 17 ( 3 ) 3 )( 3 )( 3 )( 3 )( 3 )( 3 ( 3 2000 2000 2000 16 64 128 256 512 1024 2000    
  • 8. Fermat’s Little Theorem: If p is prime and gcd(a,p)=1, then a(p-1)≡1(mod p) 8 1-2
  • 9. 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
  • 10. 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 ) (mod 1 1 p ap   ) (mod 1 1 p ap   ) 561 (mod 1 2560 
  • 11. 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
  • 12. 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 ) (mod 2 ? 1   n n 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? ) (mod 1 2 ? 1 n n   3
  • 13. Euler’s Theorem is like Fermat’s, but for composite moduli If gcd(a,n)=1, then So what’s f(n)? 13 ) (mod 1 ) ( n a n  f 4
  • 14. f(n) is the number of integers a, such that 1 ≤ a ≤ n and gcd(a,n) = 1. Examples: 1. f(10) = 4. 2. When p is prime, f(p) = ____ 3. When n =pq (product of 2 primes), f(n) = ____ 14 5
  • 15. The general formula for f(n) Example: f(12)4 [Bill Waite, RHIT 2007]            n p p p n n | 1 ) ( f 6 p are distinct primes
  • 16. 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 f(n). ) (mod 1 ) ( n a n  f 7-10