0% found this document useful (0 votes)
4 views

Lecture 3-shrt

The document covers essential mathematical concepts for cryptography, including integer arithmetic, the Euclidean algorithm for finding the GCD, and modular arithmetic. It emphasizes the importance of the modulo operator and matrices in cryptographic applications, detailing operations and properties related to these topics. Additionally, it introduces linear Diophantine equations and their solutions, highlighting their relevance in cryptography.

Uploaded by

Shahzaib Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 3-shrt

The document covers essential mathematical concepts for cryptography, including integer arithmetic, the Euclidean algorithm for finding the GCD, and modular arithmetic. It emphasizes the importance of the modulo operator and matrices in cryptographic applications, detailing operations and properties related to these topics. Additionally, it introduces linear Diophantine equations and their solutions, highlighting their relevance in cryptography.

Uploaded by

Shahzaib Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 36

MATHEMATICS FOR CRYPTOGRAPHY

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

In integer arithmetic, we use a set and a few


operations. You are familiar with this set and the
corresponding operations, but they are reviewed here
to create a background for modular arithmetic.

Topics discussed in this section:


1 Set of Integers
2 Binary Operations
3 Integer Division
4 Divisibility
5 Linear Diophantine Equations 2.3
1. Set of Integers

The set of integers, denoted by


Z, contains all integral numbers
(with no fraction) from negative
infinity to positive infinity .

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)

When we use a computer or a calculator, r and q are negative when a is


negative. How can we apply the restriction that r needs to be positive?
The solution is simple, we decrement the value of q by 1 and we add the
value of n to r to make it positive.
2.7
4. Divisbility
If a is not zero & we get r = 0 in the division relation:-
a=q×n
If the remainder is zero,
If the remainder is not zero,

a. The integer 4 divides the integer 32 because 32 = 8 × 4.


We show this as

b. The number 8 does not divide the number 42 because


42 = 5 × 8 + 2. There is a remainder, the number 2, in the
equation. We show this as
2.8
Integer Divisibility Properties
Property 1: if a|1, then a = ±1.
Property 2: if a|b and b|a, then a = ±b.
Property 3: if a|b and b|c, then a|c.
Property 4: if a|b and a|c, then
a|(b × m + c × n), where m
and n are arbitrary integers

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

GCD (140,12) = largest(1 , 2 , 4) = 4


Euclidean Algorithm
Fact 1: gcd (a, 0) = a
Fact 2: gcd (a, b) = gcd (b, r); r is remainder of dividing a by b

2.11

When gcd (a, b) = 1, we say that a and b are relatively prime.


Examples: Find GCD by Euclidean Method
Find the greatest common Find the greatest common
divisor of 2740 and 1760. divisor of 25 and 60.

2.12

gcd (2740, 1760) = 20. gcd (25, 65) = 5.


Extended Euclidean Algorithm
Given two integers a and b, we often need to
find other two integers, s and t, such that

The extended Euclidean algorithm can


calculate the gcd (a, b) and at the same
time calculate the value of s and t.
2.13
Extended Euclidean algorithm : Process

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.

We get gcd (161, 28) = 7, s = −1 and t = 6.


Ex2: Given a = 0 and b = 45, find gcd (a, b) & values of s and t.

2.16

We get gcd (0, 45) = 45, s = 0, and t = 1.


Linear Diophantine Equation
An equation of two variables x and y in the
form ax + by = c is called linear Diophantine.

 Aim: Find values of x and y that satisfied the equation.


 The equations have either no solution or particular solution.
 How to know this?
 Find d = GCD(a, b)
 If d does not divides c, then equation has no solution.
 If d divides c, then the equation has infinite solution.
 s infinite solution
Particular sol: x = (c/d)s and y = (c/d)t
0 0

General sols: x = x0 + k (b/d) and y = y0 − k(a/d)


2.17

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

The division relationship (a = q × n + r) discussed in


the previous section has two inputs (a and n) and two
outputs (q and r). In modular arithmetic, we are
interested in only one of the outputs, the remainder r.

Topics discussed in this section:


1 Modular Operator
2 Set of Residues
3 Congruence
4 Operations in Zn
5 Addition and Multiplication Tables
6 Different Sets 2.21
1. Modulo Operator
The modulo operator is shown as mod. The second input
divisor (n) is called the modulus. The output r is called
the residue.
Division Relation vs modulo operator

2.22
Examples: mod operation

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. 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

i) -7 mod 10, r = -7, r= 10-7=3


2. Set of Residues

The modulo operation creates a set, which


in modular arithmetic is referred to as the
set of least residues modulo n, or Zn.
Examples: Some Zn sets

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

Ex2: Perform the following operations (the inputs come from


either Z or Zn):
a. Add 17 to 27 in Z14.
b. Subtract 43 from 12 in Z13. 2.29

c. Multiply 123 by −10 in Z19.


Properties for Binary Operations in Zn

2.30
MATRICES

In cryptography we need to handle matrices. Although


this topic belongs to a special branch of algebra called
linear algebra, the following brief review of matrices is
necessary preparation for the study of cryptography.

Topics discussed in this section:


1 Definitions
2 Operations and Relations
3 Determinants
4 Residue Matrices
2.31
1 Definition
A matrix of size l  m

Examples of matrices

2.32
2 Operations and Relations
Ex1: Addition and subtraction of matrices

Ex2: Scalar multiplication

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.

Ex4: Multiplication of a 2 × 3 matrix by a 3 × 4 matrix.


The result is a 2 × 4 matrix.

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:

The determinant is defined only for a


square matrix. 2.35
Examples: Determinant of a matrix
Ex1: we can calculate the determinant of a 2 × 2 matrix
based on the determinant of a 1 × 1 matrix.

Ex2: calculation of the determinant of a 3 × 3 matrix.

2.36

You might also like