SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
Cryptography
Modular Arithmetic
2
• Modular arithmetic is a branch of arithmetic that deals with integers and their
remainders when divided by a fixed positive integer, which is called the modulus.
• In modular arithmetic, numbers "wrap around" when they reach the modulus value. It is
often denoted by the symbol "mod" or "%".
• Given integers , a, b, and a positive integer m (modulus), the expression a≡b(mod m)
a≡b (mod m) means that a and b have the same remainder when divided by m.
Modular Arithmetic
The modulo operation creates a set, which in modular
arithmetic is referred to as the set of least residues
modulo n, or Zn.
Set of Residues
Figure Some Zn sets
12/27/2022 3
Congruence
12/27/2022 4
● 23 mod 5 = 3
● Given integers a=17, b=29, and a positive
integer m=6 (modulus), the expression
a≡b(mod 6) means that a and b have the
same remainder when divided by 6.
● a is congruent to b modulo m, written as
a ≡ b (mod m)
Properties
12/27/2022 5
6
https://courses.cs.washington.edu/courses/cse311/23sp/lectures/lecture10-mod.pdf
7
https://courses.cs.washington.edu/courses/cse311/23sp/lectures/lecture10-mod.pdf
Inverses
When we are working in modular arithmetic, we often need to
find the inverse of a number relative to an operation. We are
normally looking for an additive inverse (relative to an addition
operation) or a multiplicative inverse (relative to a multiplication
operation).
12/27/2022 8
In Zn, two numbers a and b are additive inverses of each other if
Additive
Inverse
In modular arithmetic, each integer has
an additive inverse. The sum of an
integer and its additive inverse is
congruent to 0 modulo n.
Note
12/27/2022 9
Example
Find all additive inverse pairs in Z10.
Solution
The six pairs of additive inverses are (0, 0), (1, 9), (2, 8), (3, 7), (4,
6), and (5, 5).
12/27/2022 10
In Zn, two numbers a and b are the multiplicative inverse of each
other if
Multiplicative
Inverse
In modular arithmetic, an integer may or
may not have a multiplicative inverse.
When it does, the product of the integer
and its multiplicative inverse is
congruent to 1 modulo n.
Note
12/27/2022 11
The extended Euclidean algorithm finds
the multiplicative inverses of b in Zn
when n and b are given and
gcd (n, b) = 1.
The multiplicative inverse of b is the
value of t after being mapped to Zn.
Note
12/27/2022 12
Example
Find the multiplicative inverse of 8 in Z10.
Solution
There is no multiplicative inverse because gcd (10, 8) = 2 ≠ 1. In
other words, we cannot find any number between 0 and 9 such
that when multiplied by 8, the result is congruent to 1.
Example
Find all multiplicative inverses in Z10.
Solution
There are only three pairs: (1, 1), (3, 7) and (9, 9). The numbers
0, 2, 4, 5, 6, and 8 do not have a multiplicative inverse.
13
Example
Find all multiplicative inverse pairs in Z11.
Solution
We have seven pairs: (1, 1), (2, 6), (3, 4), (5, 9), (7, 8), (9, 5), and
(10, 10).
12/27/2022 14
Different Sets
Figure Some Zn and Zn* sets
We need to use Zn when additive
inverses are needed; we need to use Zn*
when multiplicative inverses are needed.
Note
12/27/2022 15
Exercise
• Find the multiplicative inverse of 7 in Z16
• Find the multiplicative inverse of 6 in Z9​
.
• Find all multiplicative inverse pairs in Z16.
16
Fermat's Theorem
• ap-1
mod p = 1
– where p is prime and gcd(a,p)=1
• also known as Fermat’s Little Theorem
• useful in public key and primality testing
-Suppose we have the prime number p=7. Now, let's
choose an integer a such that gcd(a,7)=1.
For simplicity, let's choose a=2.
• Now, applying Fermat's Little Theorem:
• 27−1
≡ 26
≡ 64 ≡ 1 (mod 7)
12/27/2022 17
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
– 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)
12/27/2022 18
Euler Totient Function ø(n)
• to compute ø(n) need to count number of
elements to be excluded
• in general need prime factorization, but
– for p (p prime) ø(p) = p-1
– for p.q (p,q prime) ø(p.q) = (p-1)(q-
1)
• eg.
– ø(37) = 36
– ø(21) = (3–1)×(7–1) = 2×6 = 12
12/27/2022 19
Euler's Theorem
• a generalisation of Fermat's Theorem
• aø(n)
mod n = 1
– where gcd(a,n)=1
• 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
12/27/2022 20
Modular Exponentiation
5350
mod 7
1. 350= 256+64+16+8+4+2
(350)10 =(101011110)2
2. 52 mod 7 = 25 mod 7= 4
54
mod 7 = (52
)2
mod 7 = 16 mod 7 =2
58
mod 7 =(54
)2
mod 7 = 4 mod 7 =4
516
mod 7 = (58
)2
mod 7 = 16 mod 7 =2
564
mod 7 =(516
)4
mod 7 = 16 mod 7 =2
5256
mod 7 =(564
)4
mod 7 = 16 mod 7 =2
3. 5350
mod 7
=5256+64+16+8+4+2
mod 7
= 2.2.2.4.2.4 mod 7
= 256 mod 7
= 4
12/10/2023 21

More Related Content

PPTX
Number_Theory_( ITC )_Cryptographys.pptx
PPT
ModularArithmetic.pptDDDDDDDDDDDDDDDDDDDDDDDDD
PPT
Modular Arithmetic and congruence of integers.ppt
PPT
Modular Arithmetic concept in mathematics
PDF
modul pembelajaran 4
PPTX
Mathematics of Cryptography information.
PPTX
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
PPT
Number_Theory_( ITC )_Cryptographys.pptx
ModularArithmetic.pptDDDDDDDDDDDDDDDDDDDDDDDDD
Modular Arithmetic and congruence of integers.ppt
Modular Arithmetic concept in mathematics
modul pembelajaran 4
Mathematics of Cryptography information.
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL

Similar to Cryptography Modular Arithmetic and their application.pptx (20)

DOCX
Cryptography and Network Security Principles and Practice.docx
PPT
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
PPT
PPT
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
PPT
Iss lecture 3
PPT
Number theory
PPTX
Mathematics required for Cryptography1.pptx
PPT
Cryptography and Network Security chapter 4.ppt
PPTX
Modular arithmetic
PPT
cryptography for students and for learning
PPTX
CRYPTO 2.pptx
PPTX
Part 1 Mathematical Backgroud mathsbd-1.pptx
PPTX
Report.AbstractMod.pptxeduction file to help understand the lesson
PDF
RSA Cryptosystem
PDF
RSA Cryptosystem
PDF
RSA Cryptosystem
PPT
ch04 cryptography and network security.ppt
PPT
Information Security Seminar #2
Cryptography and Network Security Principles and Practice.docx
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
ADVANCED ALGORITHMS-UNIT-3-Final.ppt
Iss lecture 3
Number theory
Mathematics required for Cryptography1.pptx
Cryptography and Network Security chapter 4.ppt
Modular arithmetic
cryptography for students and for learning
CRYPTO 2.pptx
Part 1 Mathematical Backgroud mathsbd-1.pptx
Report.AbstractMod.pptxeduction file to help understand the lesson
RSA Cryptosystem
RSA Cryptosystem
RSA Cryptosystem
ch04 cryptography and network security.ppt
Information Security Seminar #2
Ad

Recently uploaded (20)

PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Well-logging-methods_new................
PPTX
Geodesy 1.pptx...............................................
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Construction Project Organization Group 2.pptx
DOCX
573137875-Attendance-Management-System-original
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
R24 SURVEYING LAB MANUAL for civil enggi
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Internet of Things (IOT) - A guide to understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Automation-in-Manufacturing-Chapter-Introduction.pdf
Well-logging-methods_new................
Geodesy 1.pptx...............................................
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Construction Project Organization Group 2.pptx
573137875-Attendance-Management-System-original
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Ad

Cryptography Modular Arithmetic and their application.pptx

  • 2. 2 • Modular arithmetic is a branch of arithmetic that deals with integers and their remainders when divided by a fixed positive integer, which is called the modulus. • In modular arithmetic, numbers "wrap around" when they reach the modulus value. It is often denoted by the symbol "mod" or "%". • Given integers , a, b, and a positive integer m (modulus), the expression a≡b(mod m) a≡b (mod m) means that a and b have the same remainder when divided by m. Modular Arithmetic
  • 3. The modulo operation creates a set, which in modular arithmetic is referred to as the set of least residues modulo n, or Zn. Set of Residues Figure Some Zn sets 12/27/2022 3
  • 4. Congruence 12/27/2022 4 ● 23 mod 5 = 3 ● Given integers a=17, b=29, and a positive integer m=6 (modulus), the expression a≡b(mod 6) means that a and b have the same remainder when divided by 6. ● a is congruent to b modulo m, written as a ≡ b (mod m)
  • 8. Inverses When we are working in modular arithmetic, we often need to find the inverse of a number relative to an operation. We are normally looking for an additive inverse (relative to an addition operation) or a multiplicative inverse (relative to a multiplication operation). 12/27/2022 8
  • 9. In Zn, two numbers a and b are additive inverses of each other if Additive Inverse In modular arithmetic, each integer has an additive inverse. The sum of an integer and its additive inverse is congruent to 0 modulo n. Note 12/27/2022 9
  • 10. Example Find all additive inverse pairs in Z10. Solution The six pairs of additive inverses are (0, 0), (1, 9), (2, 8), (3, 7), (4, 6), and (5, 5). 12/27/2022 10
  • 11. In Zn, two numbers a and b are the multiplicative inverse of each other if Multiplicative Inverse In modular arithmetic, an integer may or may not have a multiplicative inverse. When it does, the product of the integer and its multiplicative inverse is congruent to 1 modulo n. Note 12/27/2022 11
  • 12. The extended Euclidean algorithm finds the multiplicative inverses of b in Zn when n and b are given and gcd (n, b) = 1. The multiplicative inverse of b is the value of t after being mapped to Zn. Note 12/27/2022 12
  • 13. Example Find the multiplicative inverse of 8 in Z10. Solution There is no multiplicative inverse because gcd (10, 8) = 2 ≠ 1. In other words, we cannot find any number between 0 and 9 such that when multiplied by 8, the result is congruent to 1. Example Find all multiplicative inverses in Z10. Solution There are only three pairs: (1, 1), (3, 7) and (9, 9). The numbers 0, 2, 4, 5, 6, and 8 do not have a multiplicative inverse. 13
  • 14. Example Find all multiplicative inverse pairs in Z11. Solution We have seven pairs: (1, 1), (2, 6), (3, 4), (5, 9), (7, 8), (9, 5), and (10, 10). 12/27/2022 14
  • 15. Different Sets Figure Some Zn and Zn* sets We need to use Zn when additive inverses are needed; we need to use Zn* when multiplicative inverses are needed. Note 12/27/2022 15
  • 16. Exercise • Find the multiplicative inverse of 7 in Z16 • Find the multiplicative inverse of 6 in Z9​ . • Find all multiplicative inverse pairs in Z16. 16
  • 17. Fermat's Theorem • ap-1 mod p = 1 – where p is prime and gcd(a,p)=1 • also known as Fermat’s Little Theorem • useful in public key and primality testing -Suppose we have the prime number p=7. Now, let's choose an integer a such that gcd(a,7)=1. For simplicity, let's choose a=2. • Now, applying Fermat's Little Theorem: • 27−1 ≡ 26 ≡ 64 ≡ 1 (mod 7) 12/27/2022 17
  • 18. 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 – 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) 12/27/2022 18
  • 19. Euler Totient Function ø(n) • to compute ø(n) need to count number of elements to be excluded • in general need prime factorization, but – for p (p prime) ø(p) = p-1 – for p.q (p,q prime) ø(p.q) = (p-1)(q- 1) • eg. – ø(37) = 36 – ø(21) = (3–1)×(7–1) = 2×6 = 12 12/27/2022 19
  • 20. Euler's Theorem • a generalisation of Fermat's Theorem • aø(n) mod n = 1 – where gcd(a,n)=1 • 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 12/27/2022 20
  • 21. Modular Exponentiation 5350 mod 7 1. 350= 256+64+16+8+4+2 (350)10 =(101011110)2 2. 52 mod 7 = 25 mod 7= 4 54 mod 7 = (52 )2 mod 7 = 16 mod 7 =2 58 mod 7 =(54 )2 mod 7 = 4 mod 7 =4 516 mod 7 = (58 )2 mod 7 = 16 mod 7 =2 564 mod 7 =(516 )4 mod 7 = 16 mod 7 =2 5256 mod 7 =(564 )4 mod 7 = 16 mod 7 =2 3. 5350 mod 7 =5256+64+16+8+4+2 mod 7 = 2.2.2.4.2.4 mod 7 = 256 mod 7 = 4 12/10/2023 21

Editor's Notes

  • #1: Lecture slides by Lawrie Brown for “Cryptography and Network Security”, 4/e, by William Stallings, Chapter 2 – “Classical Encryption Techniques”.