You are on page 1of 15

Republic of Iraq

Ministry of Higher Education and


Scientific Research
Al-Furat Al-Awsat Technical University
Engineering Technical College/Najaf
Al Najaf Al Ashraf, 31001. Iraq.

Fourth Year lecture notes


Communication Techniques Engineering Dept.
Engineering Technical College/Najaf 2019-2020
Lecturer: Dhurgham Al-Khaffaf
2/22/2020 Al-Furat Al-Awsat Technical Univeristy 1
Modular Arithmetic

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 2


Modular Arithmetic
• For a Mod b, divide a by b and take the
remainder.
• 14 ÷ 10 = 1 R 4
• 14 Mod 10 = 4
• 24 Mod 10 = 4

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 3


Modulus Theorem

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 4


Modulus Examples

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 5


Modular Inverses
• Inverse of 2 is ½ (2 · ½ = 1)
• Matrix Inverse: AA-1= I
• Modular Inverse for Mod m: (a · a-1) Mod m =
1
• For Modular Inverses, a and m must NOT have
any prime factors in common

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 6


Modular Inverses of Mod 26
A 1 2 5 7 9 11 15 17 19 21 23 25
A-1 1 9 21 15 3 19 7 23 11 5 17 25

Example – Find the Modular Inverse of 9 for Mod 26

9 · 3 = 27

27 Mod 26 = 1
3 is the Modular Inverse of 9 Mod 26

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 7


What is a modular inverse?
• In modular arithmetic, we do not have a
division operation. However, we do have
modular inverses.
• The modular inverse of A (mod C) is A-1
• (A * A-1) ≡ 1 (mod C) or equivalently (A * A-1)
mod C = 1
• Only the numbers co-prime to C (numbers
that share no prime factors with C) have a
modular inverse (mod C)

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 8


How to find a modular inverse
• A naive method of finding a modular inverse
for A (mod C) is:
• step 1. Calculate A * B mod C for B values 0
through C-1
• step 2. The modular inverse of A mod C is the
B value that makes A * B mod C = 1
• Note that the term B mod C can only have an
integer value 0 through C-1, so testing larger
values for B is redundant.

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 9


Example: A=3 C=7
• Step 1. Calculate A * B mod C for B values 0
through C-1
• 3 * 0 ≡ 0 (mod 7)
• 3 * 1 ≡ 3 (mod 7)
• 3 * 2 ≡ 6 (mod 7)
• 3 * 3 ≡ 9 ≡ 2 (mod 7)
• 3 * 4 ≡ 12 ≡ 5 (mod 7)
• 3 * 5 ≡ 15 (mod 7) ≡ 1 (mod 7) <------ ​FOUND
INVERSE!
• 3 * 6 ≡ 18 (mod 7) ≡ 4 (mod 7)

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 10


Example: A=2 C=6
• Step 1. Calculate A * B mod C for B values 0 through
C-1
• 2 * 0 ≡ 0 (mod 6)
• 2 * 1 ≡ 2 (mod 6)
• 2 * 2 ≡ 4 (mod 6)
• 2 * 3 ≡ 6 ≡ 0 (mod 6)
• 2 * 4 ≡ 8 ≡ 2 (mod 6)
• 2 * 5 ≡ 10 ≡ 4 (mod 6)
• No value of B makes A * B mod C = 1. Therefore, A has
no modular inverse (mod 6).
This is because 2 is not co-prime to 6 (they share the
prime factor 2).
2/22/2020 Al-Furat Al-Awsat Technical Univeristy 11
Modularly Inverse Matrices
• Calculate determinant of first matrix A, det A
• Make sure that det A has a modular inverse
for Mod 26
• Calculate the adjugate of A, adj A
• Multiply adj A by modular inverse of det A
• Calculate Mod 26 of the result to get B
• Use A to encrypt, B to decrypt

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 12


Example of finding adjugate
• In case of 2x2 matrix

• In case of 3x3 matrix  1 3 2


A   0  2 1
 1 0  2

2 1 0 1 0 2
  
 0 2 1 2 1 0
 4 1 2 4 6 7 
 3 2 1 2 1 3   
    6 0 3 Aa   1 0 1
 0 2 1 2 1 0
  2 3 2
 3 2 1 2 1 3  7 1 2 
 2 1 
 0 1 0  2 
2/22/2020 Al-Furat Al-Awsat Technical Univeristy 13
Modular Reciprocal Example

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 14


Questions?

Thank you

2/22/2020 Al-Furat Al-Awsat Technical Univeristy 15

You might also like