SlideShare a Scribd company logo
Number Theory & its Applications in
Cryptography
By
Kapil N Hande
Assistant Professor in CSE
Assistant Professor in CSE
Priyadarshini Bhagwati College of Engineering, Nagpur.
Contents
• Introduction
• Number Theory Basics
• Modular Arithmetic
• Algorithms & Theorems
2/3/2025 Kapil Hande 2
• Algorithms & Theorems
• Conclusion
Introduction
• Cryptography -- from the Greek for “secret
writing” -- is the mathematical “scrambling” of
data so that only someone with the necessary
key can “unscramble” it.
2/3/2025 Kapil Hande 3
• Cryptography allows secure transmission of
private information over insecure channels (for
example packet-switched networks).
• Cryptography also allows secure storage of
sensitive data on any computer.
Basic Terms
• Cryptology (to be very precise)
– Cryptography --- code designing
– Cryptanalysis --- code breaking
• Cryptologist:
– Cryptographer & cryptanalyst
2/3/2025 Kapil Hande 4
– Cryptographer & cryptanalyst
• Encryption/encipherment
– Scrambling data into unintelligible to
unauthorised parties
• Decryption/decipherment
– Un-scrambling
Types of Ciphers
• Private key cryptosystems/ciphers
– The secret key is shared between two parties
• Public key cryptosystems/ciphers
– The secret key is not shared and two parties
2/3/2025 Kapil Hande 5
– The secret key is not shared and two parties
can still communicate using their public keys
Overview
2/3/2025 Kapil Hande 6
Mathematics of Cryptography
• Integer Arithmetic
• Set of integers, denoted by Z, contains all integral
numbers, negative infinity to positive infinity
...}
,.........
2
,
1
,
0
,
1
,
2
..,
{......... 


Z
2/3/2025 Kapil Hande 7
• Three binary operations addition, subtraction
and multiplication
• Division is relation but it produces two output
a = q x n + r
Integer Arithmetic
Fact 1: The integer 1 has only one division,
itself
Fact 2: Any positive integer has atleast two
2/3/2025 Kapil Hande 8
Fact 2: Any positive integer has atleast two
divisors, 1 and itself.
Modular Arithmetic
• In a = q x n + r we are interested in only
one of the outputs, the remainder r
• This implies that we can change the above
relation into a binary operator with two
2/3/2025 Kapil Hande 9
relation into a binary operator with two
inputs a and n and one output r
• This operator is called modulo operator
• The second input n is called modulus
• The output r is called residue
Example
• a mod n = r
• 27 mod 5 = 2
• 35 mod 12 = 0
• -18 mod 14 = 10
2/3/2025 Kapil Hande 10
• -18 mod 14 = 10
• -7 mod 10 = 3
Modular Arithmetic
• “remainders-only” arithmetic
• Addition, subtraction, multiplication,
division relative to a modulus n
• Numbers typically between 0 and n-1
2/3/2025 Kapil Hande 11
Notation:
• x mod n means “remainder after dividing
x by n”
• x  y (mod n) means “x and y have the
same remainder mod n”
Congruence
• Concept of congruence instead of equality
• Infinite members from Z can map to one
members of Zn
• E.g. 2 mod 10=2, 12 mod 10=2,
2/3/2025 Kapil Hande 12
• E.g. 2 mod 10=2, 12 mod 10=2,
22 mod 2=2
• So 2, 12, 22 are called congruent mod 10
• We need to use congruence operator, Ξ
Congruence
• We add the phrase (mod n) to the right
side of the congruence to define the value
of modulus that makes the relationship
valid.
Important:
2/3/2025 Kapil Hande 13
Important:
a and b are said to be congruent modulo n,
if their difference a-b is an integer multiple
of n
i.e. Both numbers have same remainder
when divided by n
Example
• 2 Ξ 12(mod 10)
• 13 Ξ 23(mod 10)
• 34 Ξ 24(mod 10)
• - 8 Ξ 12(mod 10)
2/3/2025 Kapil Hande 14
• - 8 Ξ 12(mod 10)
• 3 Ξ 8 (mod 5)
• 8 Ξ 13(mod 5)
• 23 Ξ 33(mod 5)
• - 8 Ξ 2 (mod 5)
Congruence
• Equality operator maps a member Z to
itself, whereas congruence operator maps
a member from Z to a member Zn
• Equality operator is one-to-one
2/3/2025 Kapil Hande 15
• Equality operator is one-to-one
• Congruence operator is many-to-one
• Phrase (mod n) is indication of destination
set Zn
Modular Addition
• 7 + 9 = 16
• (7 + 9) mod 10 = 6
• 7 + 4 = 11
2/3/2025 Kapil Hande 16
• 7 + 4 = 11
• (7 + 4) mod 10 = 1
• 5 + 5 = 10
• (5 + 5) mod 10 = 0
Modular Subtraction
• 7 - 9 = -2
• (7 - 9) mod 10 = 8
• 7 - 4 = 3
2/3/2025 Kapil Hande 17
• 7 - 4 = 3
• (7 - 4) mod 10 = 3
• 5 - 5 = 0
• (5 - 5) mod 10 = 0
Modular Multiplication
• 7 × 9 = 63
• (7 × 9) mod 10 = 3
• 7 × 4 = 28
2/3/2025 Kapil Hande 18
• 7 × 4 = 28
• (7 × 4) mod 10 = 8
• 5 × 5 = 25
• (5 × 5) mod 10 = 5
Modular Division
• 7 ÷ 9 = 7/9
• (7 ÷ 9) mod 10 = 3
proof: 3 × 9 mod 10 = 7
• 7 ÷ 4 = 7/4
• (7 ÷ 4) mod 10 = ??
2/3/2025 Kapil Hande 19
• (7 ÷ 4) mod 10 = ??
undefined: no x such that 4 × x mod 10 = 7
• 5 ÷ 5 = 1
• (5 ÷ 5) mod 10 = ??
• undefined: more than one x such that 5 ×
x mod 10 = 5
Greatest Common Divisor GCD
• Only one GCD possible for two numbers
• The greatest common divisor (GCD) of
two numbers is the largest number that
evenly divides both
– Two numbers are relatively prime if GCD = 1
2/3/2025 Kapil Hande 20
– Two numbers are relatively prime if GCD = 1
• Examples:
– GCF (9, 10) = 1
– GCF (4, 10) = 2
– GCF (5, 10) = 5
Greatest Common Divisor GCD
• often want no common factors (except 1)
and hence numbers are relatively prime
– eg GCD(8,15) = 1
– hence 8 & 15 are relatively prime
2/3/2025 Kapil Hande 21
– hence 8 & 15 are relatively prime
Euclid’s Algorithm
• an efficient way to find the GCD(a,b)
• uses theorem that:
– GCD(a,b) = GCD(b, a mod b)
• Euclidean Algorithm to compute GCD(a,b) is:
2/3/2025 Kapil Hande 22
EUCLID(a,b)
1. A = a; B = b
2. if B = 0 return A = gcd(a, b)
3. R = A mod B
4. A = B
5. B = R
6. goto 2
Example GCD(1970,1066)
1970 = 1 x 1066 + 904 gcd(1066, 904)
1066 = 1 x 904 + 162 gcd(904, 162)
904 = 5 x 162 + 94 gcd(162, 94)
162 = 1 x 94 + 68 gcd(94, 68)
94 = 1 x 68 + 26 gcd(68, 26)
2/3/2025 Kapil Hande 23
94 = 1 x 68 + 26 gcd(68, 26)
68 = 2 x 26 + 16 gcd(26, 16)
26 = 1 x 16 + 10 gcd(16, 10)
16 = 1 x 10 + 6 gcd(10, 6)
10 = 1 x 6 + 4 gcd(6, 4)
6 = 1 x 4 + 2 gcd(4, 2)
4 = 2 x 2 + 0 gcd(2, 0)
Prime Numbers
• Asymmetric key cryptography uses primes
extensively
• Positive integers have three groups, the
number 1, primes and composites
2/3/2025 Kapil Hande 24
number 1, primes and composites
• Smallest prime is number 2
• Two positive integers, a and b, are
relatively prime, or co-prime, if gcd(a,b)=1
Prime Numbers
• If P is prime, then all integers 1 to P-1 are
relatively prime to P
• Numbers of prime is infinite
• π(n) finds the number of primes smaller
2/3/2025 Kapil Hande 25
• π(n) finds the number of primes smaller
than or equal to n
• π(1)=0, π(2)=1, π(3)=2, π(10)=4, π(20)=8,
π(100)=25
• If n is very large, we can only use
approximation
Euler Totient Function ø(n)
• when doing arithmetic modulo n
• complete set of residues is: 0..n-1
• reduced set of residues is those numbers
(residues) which are relatively prime to n
2/3/2025 Kapil Hande 26
(residues) which are relatively prime to n
– eg for n=10,
– complete set of residues is {0,1,2,3,4,5,6,7,8,9}
– reduced set of residues is {1,3,7,9}
• number of elements in reduced set of residues is
called the Euler Totient Function ø(n)
Euler Totient Function ø(n)
• to compute ø(n) need to count number of
residues to be excluded
• in general need prime factorization, but
– for p (p prime) ø(p) = p-1
2/3/2025 Kapil Hande 27
– for p (p prime) ø(p) = p-1
– for p.q (p,q prime) ø(pq) =(p-1)x(q-1)
• eg.
ø(37) = 36
ø(21) = (3–1)x(7–1) = 2x6 = 12
Euler's Theorem
• a generalisation of Fermat's Theorem
• aø(n) = 1 (mod n)
– for any a,n where gcd(a,n)=1
• eg.
2/3/2025 Kapil Hande 28
• eg.
a=3;n=10; ø(10)=4;
hence 34 = 81 = 1 mod 10
a=2;n=11; ø(11)=10;
hence 210 = 1024 = 1 mod 11
RSA ALGORITHM
• Block Cipher, plaintext and ciphertext are
integers between 0 and n-1 for some n
• n is 1024 bits or 309 decimal digits
• Uses an expression with exponentials
2/3/2025 Kapil Hande 29
• Uses an expression with exponentials
• M – Plaintext block C – Ciphertext block
• C = Me mod n
• M = Cd mod n = (Me)d mod n =Med mod n
RSA ALGORITHM
• Sender knows value of e, and only
receiver knows value of d
• So public key is PU={e,n}
• Private key is PR={d,n}
2/3/2025 Kapil Hande 30
• Private key is PR={d,n}
• It is relatively easy to calculate Me mod n
and Cd mod n for all M<n
• It is infeasible to determine d given e and
n
RSA ALGORITHM
• p,q two primes (private & chosen)
• n=pq (public & calculated)
• e, with gcd(Ø(n), e)=1,
1<e<Ø(n) (public & chosen)
2/3/2025 Kapil Hande 31
1<e<Ø(n) (public & chosen)
• d Ξe-1 (mod Ø(n)) (private & calculated)
Key Generation
• Select p and q p≠q and primes
• Find n=pxq
• Find Ø(n)=(p-1)(q-1)
• Select e such that gcd(Ø(n),e)=1
2/3/2025 Kapil Hande 32
• Select e such that gcd(Ø(n),e)=1
1<e<Ø(n)
• Find d d Ξe-1 (mod Ø(n))
• Public Key PU={e,n}
• Private Key PR={d,n}
Encryption
• M<n C = Me mod n
Decryption
2/3/2025 Kapil Hande 33
Decryption
• M = Cd mod n
RSA Example
• Let p=5, q=11, e=3, M=9
• n=pq=11x5=55
• Ø(n)=(5-1)(11-1)=4x10=40
• e=3
2/3/2025 Kapil Hande 34
• e=3
• So d.e Ξ1 (mod 40)
d.3 Ξ1 (mod 40)
27.3 Ξ1 (mod 40) So d=27
RSA Example
• So PU={3,55} and PR={27,55}
• C = Me mod n =93 mod 55
• C = 14
• M = Cd
mod n= 1427 mod 55
2/3/2025 Kapil Hande 35
• M = Cd
mod n= 1427 mod 55
• So 1427 mod 55
=[(141 mod 55).(142 mod 55).(144 mod 55).(148 mod 55).
(148 mod 55).(144 mod 55)] mod 55
= [14x31x26x16x16x26] mod 55 = 75106304 mod 55 = 9
So M = 9 i.e. plaintext
Comparison
Algorithm Encryption/
Decryption
Digital
Signature
Key
Exchange
RSA Yes Yes Yes
Elliptic Yes Yes Yes
2/3/2025 Kapil Hande 36
Elliptic
Curve
Yes Yes Yes
Diffie-
Hellman
No No Yes
DSS No Yes No
Conclusions
• Number theory has great importance in
cryptography
• Need randomness and uniqueness in
choosing large numbers
2/3/2025 Kapil Hande 37
choosing large numbers
• Primes need to be used heavily
• RSA, secure and powerful algorithm for
key exchange, digital signature &
En/Decryption
References
• www.williamstallings.com
• http://ijns.femto.com.tw/
• http://www.cacr.math.uwaterloo.ca/hac/
• www.rsa.com
2/3/2025 Kapil Hande 38
• www.rsa.com
Thank You!
2/3/2025 Kapil Hande 39
Thank You!

More Related Content

PPTX
Modular arithmetic
PPTX
It is about the number theory concept and integers
PPTX
Euclidean_Algorithm_Num_Theory_Presentation.pptx
PPTX
Euclidean_Algorithm_NT_Presentation.pptx
PPT
Module - III.pptssssssssssssssssssssssssssssssssssssssssssssssss
PPT
daaadafrhdncxfbfbgdngfmfhmhagshh_unit_i.ppt
PDF
RSA ALGORITHM
Modular arithmetic
It is about the number theory concept and integers
Euclidean_Algorithm_Num_Theory_Presentation.pptx
Euclidean_Algorithm_NT_Presentation.pptx
Module - III.pptssssssssssssssssssssssssssssssssssssssssssssssss
daaadafrhdncxfbfbgdngfmfhmhagshh_unit_i.ppt
RSA ALGORITHM

Similar to Number Theory and Its Applications in Cryptography (20)

PPTX
Homomorphic Encryption
PPT
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
PPT
PPT
data unit notes from department of computer science
PPT
MFCS-17.ppt
PDF
A study on number theory and its applications
PDF
Elliptic Curve Cryptography and Zero Knowledge Proof
PDF
Elliptic curve cryptography and zero knowledge proof
PPT
555_Spring12_topic06.ppt
PPTX
DAA - UNIT 4 - Engineering.pptx
PPTX
Greatest_Common_Divisor_Presentation.pptx
PPTX
Greatest_Common_Divisor_Presentation.pptx
PDF
lecture5.pdf
PDF
sheet6.pdf
PDF
doc6.pdf
PDF
paper6.pdf
PDF
"Mesh of Periodic Minimal Surfaces in CGAL."
PPT
PPT
ResidueNumberSystems_ieee_bangalore (1)(1).ppt
PPT
Assume that the organization uses a weak random number generator or an algori...
Homomorphic Encryption
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
data unit notes from department of computer science
MFCS-17.ppt
A study on number theory and its applications
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic curve cryptography and zero knowledge proof
555_Spring12_topic06.ppt
DAA - UNIT 4 - Engineering.pptx
Greatest_Common_Divisor_Presentation.pptx
Greatest_Common_Divisor_Presentation.pptx
lecture5.pdf
sheet6.pdf
doc6.pdf
paper6.pdf
"Mesh of Periodic Minimal Surfaces in CGAL."
ResidueNumberSystems_ieee_bangalore (1)(1).ppt
Assume that the organization uses a weak random number generator or an algori...
Ad

More from kapilhande1 (8)

PDF
Signal conversion techniques and compression
PDF
Introduction to Data Communication concepts
PDF
Knowledge Representation techniques in Artificial Intelligence
PDF
Searching Techniques in Artificial Intelligence
PDF
Introduction To Artificial Intelligence and applications
PDF
Ethics In Information Technology Intellectual Property
PDF
Ethics in Information Technology - Privacy
PDF
Ethics in Information Technology - An Overview
Signal conversion techniques and compression
Introduction to Data Communication concepts
Knowledge Representation techniques in Artificial Intelligence
Searching Techniques in Artificial Intelligence
Introduction To Artificial Intelligence and applications
Ethics In Information Technology Intellectual Property
Ethics in Information Technology - Privacy
Ethics in Information Technology - An Overview
Ad

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Insiders guide to clinical Medicine.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Institutional Correction lecture only . . .
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
master seminar digital applications in india
PDF
Classroom Observation Tools for Teachers
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
2.FourierTransform-ShortQuestionswithAnswers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Insiders guide to clinical Medicine.pdf
Computing-Curriculum for Schools in Ghana
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Institutional Correction lecture only . . .
Microbial disease of the cardiovascular and lymphatic systems
master seminar digital applications in india
Classroom Observation Tools for Teachers
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Number Theory and Its Applications in Cryptography

  • 1. Number Theory & its Applications in Cryptography By Kapil N Hande Assistant Professor in CSE Assistant Professor in CSE Priyadarshini Bhagwati College of Engineering, Nagpur.
  • 2. Contents • Introduction • Number Theory Basics • Modular Arithmetic • Algorithms & Theorems 2/3/2025 Kapil Hande 2 • Algorithms & Theorems • Conclusion
  • 3. Introduction • Cryptography -- from the Greek for “secret writing” -- is the mathematical “scrambling” of data so that only someone with the necessary key can “unscramble” it. 2/3/2025 Kapil Hande 3 • Cryptography allows secure transmission of private information over insecure channels (for example packet-switched networks). • Cryptography also allows secure storage of sensitive data on any computer.
  • 4. Basic Terms • Cryptology (to be very precise) – Cryptography --- code designing – Cryptanalysis --- code breaking • Cryptologist: – Cryptographer & cryptanalyst 2/3/2025 Kapil Hande 4 – Cryptographer & cryptanalyst • Encryption/encipherment – Scrambling data into unintelligible to unauthorised parties • Decryption/decipherment – Un-scrambling
  • 5. Types of Ciphers • Private key cryptosystems/ciphers – The secret key is shared between two parties • Public key cryptosystems/ciphers – The secret key is not shared and two parties 2/3/2025 Kapil Hande 5 – The secret key is not shared and two parties can still communicate using their public keys
  • 7. Mathematics of Cryptography • Integer Arithmetic • Set of integers, denoted by Z, contains all integral numbers, negative infinity to positive infinity ...} ,......... 2 , 1 , 0 , 1 , 2 .., {.........    Z 2/3/2025 Kapil Hande 7 • Three binary operations addition, subtraction and multiplication • Division is relation but it produces two output a = q x n + r
  • 8. Integer Arithmetic Fact 1: The integer 1 has only one division, itself Fact 2: Any positive integer has atleast two 2/3/2025 Kapil Hande 8 Fact 2: Any positive integer has atleast two divisors, 1 and itself.
  • 9. Modular Arithmetic • In a = q x n + r we are interested in only one of the outputs, the remainder r • This implies that we can change the above relation into a binary operator with two 2/3/2025 Kapil Hande 9 relation into a binary operator with two inputs a and n and one output r • This operator is called modulo operator • The second input n is called modulus • The output r is called residue
  • 10. Example • a mod n = r • 27 mod 5 = 2 • 35 mod 12 = 0 • -18 mod 14 = 10 2/3/2025 Kapil Hande 10 • -18 mod 14 = 10 • -7 mod 10 = 3
  • 11. Modular Arithmetic • “remainders-only” arithmetic • Addition, subtraction, multiplication, division relative to a modulus n • Numbers typically between 0 and n-1 2/3/2025 Kapil Hande 11 Notation: • x mod n means “remainder after dividing x by n” • x  y (mod n) means “x and y have the same remainder mod n”
  • 12. Congruence • Concept of congruence instead of equality • Infinite members from Z can map to one members of Zn • E.g. 2 mod 10=2, 12 mod 10=2, 2/3/2025 Kapil Hande 12 • E.g. 2 mod 10=2, 12 mod 10=2, 22 mod 2=2 • So 2, 12, 22 are called congruent mod 10 • We need to use congruence operator, Ξ
  • 13. Congruence • We add the phrase (mod n) to the right side of the congruence to define the value of modulus that makes the relationship valid. Important: 2/3/2025 Kapil Hande 13 Important: a and b are said to be congruent modulo n, if their difference a-b is an integer multiple of n i.e. Both numbers have same remainder when divided by n
  • 14. Example • 2 Ξ 12(mod 10) • 13 Ξ 23(mod 10) • 34 Ξ 24(mod 10) • - 8 Ξ 12(mod 10) 2/3/2025 Kapil Hande 14 • - 8 Ξ 12(mod 10) • 3 Ξ 8 (mod 5) • 8 Ξ 13(mod 5) • 23 Ξ 33(mod 5) • - 8 Ξ 2 (mod 5)
  • 15. Congruence • Equality operator maps a member Z to itself, whereas congruence operator maps a member from Z to a member Zn • Equality operator is one-to-one 2/3/2025 Kapil Hande 15 • Equality operator is one-to-one • Congruence operator is many-to-one • Phrase (mod n) is indication of destination set Zn
  • 16. Modular Addition • 7 + 9 = 16 • (7 + 9) mod 10 = 6 • 7 + 4 = 11 2/3/2025 Kapil Hande 16 • 7 + 4 = 11 • (7 + 4) mod 10 = 1 • 5 + 5 = 10 • (5 + 5) mod 10 = 0
  • 17. Modular Subtraction • 7 - 9 = -2 • (7 - 9) mod 10 = 8 • 7 - 4 = 3 2/3/2025 Kapil Hande 17 • 7 - 4 = 3 • (7 - 4) mod 10 = 3 • 5 - 5 = 0 • (5 - 5) mod 10 = 0
  • 18. Modular Multiplication • 7 × 9 = 63 • (7 × 9) mod 10 = 3 • 7 × 4 = 28 2/3/2025 Kapil Hande 18 • 7 × 4 = 28 • (7 × 4) mod 10 = 8 • 5 × 5 = 25 • (5 × 5) mod 10 = 5
  • 19. Modular Division • 7 ÷ 9 = 7/9 • (7 ÷ 9) mod 10 = 3 proof: 3 × 9 mod 10 = 7 • 7 ÷ 4 = 7/4 • (7 ÷ 4) mod 10 = ?? 2/3/2025 Kapil Hande 19 • (7 ÷ 4) mod 10 = ?? undefined: no x such that 4 × x mod 10 = 7 • 5 ÷ 5 = 1 • (5 ÷ 5) mod 10 = ?? • undefined: more than one x such that 5 × x mod 10 = 5
  • 20. Greatest Common Divisor GCD • Only one GCD possible for two numbers • The greatest common divisor (GCD) of two numbers is the largest number that evenly divides both – Two numbers are relatively prime if GCD = 1 2/3/2025 Kapil Hande 20 – Two numbers are relatively prime if GCD = 1 • Examples: – GCF (9, 10) = 1 – GCF (4, 10) = 2 – GCF (5, 10) = 5
  • 21. Greatest Common Divisor GCD • often want no common factors (except 1) and hence numbers are relatively prime – eg GCD(8,15) = 1 – hence 8 & 15 are relatively prime 2/3/2025 Kapil Hande 21 – hence 8 & 15 are relatively prime
  • 22. Euclid’s Algorithm • an efficient way to find the GCD(a,b) • uses theorem that: – GCD(a,b) = GCD(b, a mod b) • Euclidean Algorithm to compute GCD(a,b) is: 2/3/2025 Kapil Hande 22 EUCLID(a,b) 1. A = a; B = b 2. if B = 0 return A = gcd(a, b) 3. R = A mod B 4. A = B 5. B = R 6. goto 2
  • 23. Example GCD(1970,1066) 1970 = 1 x 1066 + 904 gcd(1066, 904) 1066 = 1 x 904 + 162 gcd(904, 162) 904 = 5 x 162 + 94 gcd(162, 94) 162 = 1 x 94 + 68 gcd(94, 68) 94 = 1 x 68 + 26 gcd(68, 26) 2/3/2025 Kapil Hande 23 94 = 1 x 68 + 26 gcd(68, 26) 68 = 2 x 26 + 16 gcd(26, 16) 26 = 1 x 16 + 10 gcd(16, 10) 16 = 1 x 10 + 6 gcd(10, 6) 10 = 1 x 6 + 4 gcd(6, 4) 6 = 1 x 4 + 2 gcd(4, 2) 4 = 2 x 2 + 0 gcd(2, 0)
  • 24. Prime Numbers • Asymmetric key cryptography uses primes extensively • Positive integers have three groups, the number 1, primes and composites 2/3/2025 Kapil Hande 24 number 1, primes and composites • Smallest prime is number 2 • Two positive integers, a and b, are relatively prime, or co-prime, if gcd(a,b)=1
  • 25. Prime Numbers • If P is prime, then all integers 1 to P-1 are relatively prime to P • Numbers of prime is infinite • π(n) finds the number of primes smaller 2/3/2025 Kapil Hande 25 • π(n) finds the number of primes smaller than or equal to n • π(1)=0, π(2)=1, π(3)=2, π(10)=4, π(20)=8, π(100)=25 • If n is very large, we can only use approximation
  • 26. Euler Totient Function ø(n) • when doing arithmetic modulo n • complete set of residues is: 0..n-1 • reduced set of residues is those numbers (residues) which are relatively prime to n 2/3/2025 Kapil Hande 26 (residues) which are relatively prime to n – eg for n=10, – complete set of residues is {0,1,2,3,4,5,6,7,8,9} – reduced set of residues is {1,3,7,9} • number of elements in reduced set of residues is called the Euler Totient Function ø(n)
  • 27. Euler Totient Function ø(n) • to compute ø(n) need to count number of residues to be excluded • in general need prime factorization, but – for p (p prime) ø(p) = p-1 2/3/2025 Kapil Hande 27 – for p (p prime) ø(p) = p-1 – for p.q (p,q prime) ø(pq) =(p-1)x(q-1) • eg. ø(37) = 36 ø(21) = (3–1)x(7–1) = 2x6 = 12
  • 28. Euler's Theorem • a generalisation of Fermat's Theorem • aø(n) = 1 (mod n) – for any a,n where gcd(a,n)=1 • eg. 2/3/2025 Kapil Hande 28 • eg. a=3;n=10; ø(10)=4; hence 34 = 81 = 1 mod 10 a=2;n=11; ø(11)=10; hence 210 = 1024 = 1 mod 11
  • 29. RSA ALGORITHM • Block Cipher, plaintext and ciphertext are integers between 0 and n-1 for some n • n is 1024 bits or 309 decimal digits • Uses an expression with exponentials 2/3/2025 Kapil Hande 29 • Uses an expression with exponentials • M – Plaintext block C – Ciphertext block • C = Me mod n • M = Cd mod n = (Me)d mod n =Med mod n
  • 30. RSA ALGORITHM • Sender knows value of e, and only receiver knows value of d • So public key is PU={e,n} • Private key is PR={d,n} 2/3/2025 Kapil Hande 30 • Private key is PR={d,n} • It is relatively easy to calculate Me mod n and Cd mod n for all M<n • It is infeasible to determine d given e and n
  • 31. RSA ALGORITHM • p,q two primes (private & chosen) • n=pq (public & calculated) • e, with gcd(Ø(n), e)=1, 1<e<Ø(n) (public & chosen) 2/3/2025 Kapil Hande 31 1<e<Ø(n) (public & chosen) • d Ξe-1 (mod Ø(n)) (private & calculated)
  • 32. Key Generation • Select p and q p≠q and primes • Find n=pxq • Find Ø(n)=(p-1)(q-1) • Select e such that gcd(Ø(n),e)=1 2/3/2025 Kapil Hande 32 • Select e such that gcd(Ø(n),e)=1 1<e<Ø(n) • Find d d Ξe-1 (mod Ø(n)) • Public Key PU={e,n} • Private Key PR={d,n}
  • 33. Encryption • M<n C = Me mod n Decryption 2/3/2025 Kapil Hande 33 Decryption • M = Cd mod n
  • 34. RSA Example • Let p=5, q=11, e=3, M=9 • n=pq=11x5=55 • Ø(n)=(5-1)(11-1)=4x10=40 • e=3 2/3/2025 Kapil Hande 34 • e=3 • So d.e Ξ1 (mod 40) d.3 Ξ1 (mod 40) 27.3 Ξ1 (mod 40) So d=27
  • 35. RSA Example • So PU={3,55} and PR={27,55} • C = Me mod n =93 mod 55 • C = 14 • M = Cd mod n= 1427 mod 55 2/3/2025 Kapil Hande 35 • M = Cd mod n= 1427 mod 55 • So 1427 mod 55 =[(141 mod 55).(142 mod 55).(144 mod 55).(148 mod 55). (148 mod 55).(144 mod 55)] mod 55 = [14x31x26x16x16x26] mod 55 = 75106304 mod 55 = 9 So M = 9 i.e. plaintext
  • 36. Comparison Algorithm Encryption/ Decryption Digital Signature Key Exchange RSA Yes Yes Yes Elliptic Yes Yes Yes 2/3/2025 Kapil Hande 36 Elliptic Curve Yes Yes Yes Diffie- Hellman No No Yes DSS No Yes No
  • 37. Conclusions • Number theory has great importance in cryptography • Need randomness and uniqueness in choosing large numbers 2/3/2025 Kapil Hande 37 choosing large numbers • Primes need to be used heavily • RSA, secure and powerful algorithm for key exchange, digital signature & En/Decryption
  • 38. References • www.williamstallings.com • http://ijns.femto.com.tw/ • http://www.cacr.math.uwaterloo.ca/hac/ • www.rsa.com 2/3/2025 Kapil Hande 38 • www.rsa.com
  • 39. Thank You! 2/3/2025 Kapil Hande 39 Thank You!