CH 02
CH 02
Mathematics of
Cryptography
Part I: Modular Arithmetic, Congruence,
and Matrices
2.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 2
Objectives
To review integer arithmetic, concentrating on divisibility
and finding the greatest common divisor using the Euclidean
algorithm
To understand how the extended Euclidean algorithm can be
used to solve linear Diophantine equations, to solve linear
congruent equations, and to find the multiplicative inverses
To emphasize the importance of modular arithmetic and
the modulo operator, because they are extensively used in
cryptography
To emphasize and review matrices and operations on residue
matrices that are extensively used in cryptography
To solve a set of congruent equations using residue matrices
2.2
2-1 INTEGER ARITHMETIC
2.3
2.1.1 Set of Integers
2.4
2.1.2 Binary Operations
In cryptography, we are interested in three binary
operations applied to the set of integers. A binary
operation takes two inputs and creates one output.
2.5
2.1.2 Continued
Example 2.1
2.6
2.1.3 Integer Division
a=q×n+r
2.7
2.1.3 Continued
Example 2.2
Assume that a = 255 and n = 11. We can find q = 23 and R = 2
using the division algorithm.
Figure 2.3 Example 2.2, finding the quotient and the remainder
2.8
2.1.3 Continued
Figure 2.4 Division algorithm for integers
2.9
2.1.4 Divisbility
a=q×n
2.10
2.1.4 Continued
Example 2.4
2.11
2.1.4 Continued
Properties
2.12
2.1.4 Continued
Example 2.5
2.13
2.1.4 Continued
Example 2.6
Note
2.16
Figure 2.6 Common divisors of two integers
2.1.4 Continued
2.18
2.1.4 Continued
Note Euclidean Algorithm
Fact 2: example
gcd(36,10)=gcd(10,6)=gcd(6,4)=gcd(4,2)=gcd(2,0=2
)
gcd(36,10)=> 36=3×10+6
gcd(10,6)=> 10=1×6+4
gcd(6,4)=> 6=1×4+2
gcd(4,2)=> 4=2×2+0
gcd(2,0)=> 2
2.19
2.1.4 Continued
Figure 2.7 Euclidean Algorithm
2.20
2.1.4 Continued
Note
example-
8 and 15 are relatively prime because the positive divisors of 8 are 1, 2, 4,
and 8, and the positive divisors of 15 are 1, 3, 5, and 15. So 1 is the only
integer on both lists.
Question:
Find the greatest common divisor of 2740 and 1760?
Find the greatest common divisor of 25 and 60?
2.21
2.1.4 Continued
Example 2.7
Find the greatest common divisor of 2740 and 1760.
Solution
We have gcd (2740, 1760) = 20.
2.22
2.1.4 Continued
Example 2.8
Find the greatest common divisor of 25 and 60.
Solution
We have gcd (25, 65) = 5.
2.23
2.1.4 Continued
Extended Euclidean Algorithm
Given two integers a and b, we often need to find other two
integers, s and t, such that
2.24
2.1.4 Continued
Figure 2.8.a Extended Euclidean algorithm, part a
2.25
2.1.4 Continued
Figure 2.8.b Extended Euclidean algorithm, part b
2.26
2.1.4 Continued
Example 2.9
Given a = 161 and b = 28, find gcd (a, b) and the values of s
and t.
Solution
We get gcd (161, 28) = 7, s = −1 and t = 6.
s=s1-qs2
t=t1-qt2
2.27
2.1.4 Continued
Example 2.10
Given a = 17 and b = 0, find gcd (a, b) and the values of s
and t.
Solution
We get gcd (17, 0) = 17, s = 1, and t = 0.
2.28
2.1.4 Continued
Example 2.11
Solution
We get gcd (0, 45) = 45, s = 0, and t = 1.
2.29
2-2 MODULAR ARITHMETIC
2.34
2.1.4 Continued
Example 2.14
Find the result of the following operations:
a. 27 mod 5 b. 36 mod 12
c. −18 mod 14 d. −7 mod 10
Solution
a. Dividing 27 by 5 results in r = 2
b. Dividing 36 by 12 results in r = 0.
c. Dividing −18 by 14 results in r = −4. However, we need to add
the modulus (14) to make it nonnegative. We have r = −4 + 14 =
10. This means that −18 mod 14 = 10 After adding the modulus r
= 10
d. Dividing −7 by 10 results in r = −7. After adding the modulus
to −7, r = 3. This means that −7 mod 10 = 3.
35
2.2.2 Set of Residues
2.36
2.2.3 Congruence
2.37
2.2.3 Continued
Figure 2.11 Concept of congruence
2.38
2.2.3 Continued
Example 2.15
2.39
2.2.4 Operation in Zn
2.40
2.2.4 Continued
Example 2.16
Perform the following operations (the inputs come from Zn):
a. Add 7 to 14 in Z15.
b. Subtract 11 from 7 in Z13.
c. Multiply 11 by 7 in Z20.
Solution
2.41
2.2.4 Continued
Properties
2.42
2.2.4 Continued
Figure 2.14 Properties of mode operator
2.43
2.2.4 Continued
Example 2.18
2.44
2.2.5 Inverses
2.45
2.2.5 Continue
Additive Inverse
Note
Solution
The six pairs of additive inverses are (0, 0), (1, 9), (2, 8), (3, 7),
(4, 6), and (5, 5).
2.47
1. Additive inverse of 144mod97
=144mod97
=47
Now, additive inverse of 47mod97
47+(-47) ≡0 mod97
97-47=50
Note
2.49
multiplicative inverse of 26 mod 11
q a b r t1 t2 t
0 11 26 11 0 1 0
2 26 11 4 1 0 1
2 11 4 3 0 1 -2
1 4 3 1 1 -2 3
3 3 1 0 -2 3 -11
1 0 3
2.50
multiplicative inverse of 3 mod 11
q a b r t1 t2 t
3 11 3 2 0 1 -3
1 3 2 1 1 -3 4
2 2 1 0 -3 4 -11
1 0 4 -11
2.51
Questions on multiplicative inverse:
1.17mod29
2.27mod392
3.2021mod4032
4.9mod26
2.52
2-3 MATRICES
2.53
2.3.1 Definition
2.54
2.3.1 Continued
2.55
2.3.2 Operations and Relations
Example 2.28
2.56
2.3.2 Continued
Example 2. 29
2.57