Lecture 3-shrt
Lecture 3-shrt
CRYPTOGRAPH
Y D R. FAHEEM MUSHTAQ
AND
NETWORK
SECURITY
Objectives
Toreview integer arithmetic, concentrating
on divisibility and finding the Greatest
Common Divisor (GCD) using the
Euclidean algorithm.
Tounderstand how the extended Euclidean
algorithm can be used to solve linear
Diophantine equations, linear congruent
equations, and to find the multiplicative
inverses
2.2
INTEGER ARITHMETIC
2.4
2 Binary Operations
In cryptography, we are interested in three binary
operations ( + , - , X ) applied to the set of integers. A
binary operation takes two inputs and creates one output.
Examples:
2.5
3 Integer Division
In integer arithmetic, if we divide a (divident) by n
(divisor), we can get q (quotient) & r (remainder) . The
relationship between these four integers can be shown as
a=q×n+r
Example
2.6
Integer Division Relation
(not operation as more than one output)
2.9
Greatest Common Divisor of two integers
The greatest common divisor of two
positive integers is the largest integer
that can divide both integers.
2.10
2.11
2.12
2.14
Extended Euclidean algorithm: Algorithm
2.15
Examples: Extended Euclidean Agorithm
Ex1: Given a = 161 and b = 28, find gcd (a, b) & values of s and t.
2.16
where k is an integer
Example : Solving Diophanite Equation
Ex1: Find the particular & general solutions to the equation:-
21x + 14y = 35
Solution: by using EEA we get gcd(21,14) =7, s=1 and t= -1
Ex2: Imagine we want to cash a $100 check and get some $20 and
some $5 bills. We have many choices, which we can find by
solving the corresponding Diophantine equation 20x + 5y = 100.
Since d = gcd (20, 5) = 5 and 5 | 100, the equation has an infinite
number of solutions, but only a few of them are acceptable in this
case The general solutions with x and y nonnegative are:-
(0, 20), (1, 16), (2, 12), (3, 8), (4, 4), (5, 0).
2.18
MATHEMATICS FOR CRYPTOGRAPHY
CRYPTOGRAPH
Y D R. FAHEEM MUSHTAQ
AND Assistant Professor
NETWORK
SECURITY
Objectives
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.20
MODULAR ARITHMETIC
2.22
Examples: mod operation
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. After adding the modulus r
= 10
i) a = n * q + r, -18 = 14 (-2)+ r , -18 = -28 + r, -18+28 = r, 10=r
ii) -18 mod 14, r = -4, r = 14-4=10
d. Dividing −7 by 10 results in r = −7. After adding the modulus to
−7, r = 3. 2.23
2.24
3 Congruence
Two integers are congruent, if they have same residue for
a given modulus. we use the congruence operator ( ≡ ).
For example, we write:
2.25
Residue Classes
A residue class [a] or [a]n is the set of integers
congruent modulo n. (in following example n=5)
2.26
Comparison of Z and Zn using graphs
2.27
4. Binary Operation in Zn
The three binary operations that we discussed for the set
Z can also be defined for the set Zn. The result may need
to be mapped to Zn using the mod operator.
Binary operations in Zn
2.28
Examples: Binary Operations in Zn
Ex1: Perform following operations (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.30
MATRICES
Examples of matrices
2.32
2 Operations and Relations
Ex1: Addition and subtraction of matrices
2.33
2 Operations and Relations….cont’d
Ex3:Multiplication of a row matrix (1 × 3) by a column matrix (3 × 1)
The result is a matrix of size 1 × 1.
2.34
3 Determinant
The determinant of a square matrix A of size m × m
denoted as det (A) is a scalar calculated recursively
as shown below:
2.36