0% found this document useful (0 votes)
85 views44 pages

Unit-1 Mathematics On Cryptography

This document provides an overview of the mathematics concepts used in cryptography. It discusses sets of integers, binary operations, integer division, Euclidean algorithm, extended Euclidean algorithm, linear Diophantine equations, modular arithmetic, matrices, determinants, and inverses. Key topics include modular arithmetic, congruences, linear congruence, modular inverses, and applying concepts like the extended Euclidean algorithm to solve problems in modular arithmetic.

Uploaded by

SK Endless Soul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views44 pages

Unit-1 Mathematics On Cryptography

This document provides an overview of the mathematics concepts used in cryptography. It discusses sets of integers, binary operations, integer division, Euclidean algorithm, extended Euclidean algorithm, linear Diophantine equations, modular arithmetic, matrices, determinants, and inverses. Key topics include modular arithmetic, congruences, linear congruence, modular inverses, and applying concepts like the extended Euclidean algorithm to solve problems in modular arithmetic.

Uploaded by

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

Cryptography and Network Security

UNIT-1
Basic Principles
(Mathematics of Cryptography)

Dr. Dwiti Krishna Bebarta


Mathematics of Cryptography
Topics to Discuss
1. Set of Integers
2. Binary Operations
3. Integer Division
4. Divisibility
5. Euclidean Algorithm
6. Extended Euclidean Algorithm
7. Linear Diophantine Equations
8. Modular Arithmetic
9. Matrices
10. Linear Congruence
Set of Integers
• The set of integers, denoted by Z, contains all integral numbers
(with no fraction) from negative infinity to positive infinity. The
set of integers defined as
• Z = {……., -2, -1, 0, 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
(+ve or –ve) and creates one output.
• Z = {……., -2, -1, 0, 1, 2, ………..}
A B

+, -, ×
C

Z = {……., -2, -1, 0, 1, 2, ………..}


Integer Division (Finding the quotient and the remainder)
• In integer arithmetic, if we divide a by n, we can get q and r.
• The relationship between these four integers can be shown as
a= q×n+ r
Assume that a=255 and n=11. apply division algorithm 255/11,
then
q=23 and R=2 using the division algorithm.

if a is positive then q and R is positive.


If a is negative then q is negative and R is positive. How?
• -33/10
• If a= q×n+ r
• Then (-3×10)+(-3) = -33
• to make positive remainder
• a= ((-q-1)×n)+(-r+n) add divisor to negative remainder
• ((-3-1)×10)+(-3+10)
• => -33 and positive remainder is 7

• Solve: -255/11
r = a%b

Find GCD(2740,1760)
GCD(131,5)
• GCD(88,220)

r1 r2 q r
88 220 88/220=0 88
220 88 220/88=2 44
88 44 88/44=2 00
44 00 ---- 44

Find GCD(2740,1760) Non-Recursive


GCD(131,5) r= r1-q×r2
r1=r2
r2=r
Recursive Concept 1st call
GCD(36,10)
int gcd(int a, int b)
2nd call
{ GCD(10,6)
if (b == 0) 3rd call
return a; GCD(6,4)
return gcd(b, a% b); 4th call
} GCD(4,2)
5th call
GCD(2,0)
6th Call
=2 since b=0
• In arithmetic and computer programming, the extended
Euclidean algorithm is an extension to the Euclidean algorithm,
and computes, in addition to the greatest common divisor (gcd)
of integers a and b.
• It allows one to compute also, with almost no extra cost, the
quotients of a and b by their greatest common divisor. This
process is called the extended Euclidean algorithm.
• The extended Euclidean algorithm is particularly useful
when a and b are co-prime. With that provision, x is the modular
multiplicative inverse of a modulo b, and y is the modular
multiplicative inverse of b modulo a.
• Co-prime numbers are the numbers whose common factor is
only 1. There should be a minimum of two numbers to form a set
of co-prime numbers. Such numbers have only 1 as their highest
common factor, for example, {4 and 7}, {5, 7, 9} are co-prime
numbers.
• Is 18 and 35 a Co-prime number?
Given a=161,
b=27, find
GCD(a,b) and
the values of s
and t

Given a=17,
b=0, find
GCD(a,b) and
the values of
s=1 and t=0

Given a=0,
b=45, find
GCD(a,b) and
the values of
s=0 and t=1
The Extended Euclidean Algorithm
GCD(a,b) = s*a + t*b

r1 r2 q r s1 s2 s t1 t2 t
88 220 88/220=0 88 1 0 1 0 1 0
220 88 220/88=2 44 0 1 -2 1 0 1
88 44 88/44=2 00 1 -2 5 0 1 -2
44 00 ---- --- -2 5 --- 1 -2 ---
Since r2=0, GCD(88,220)=44, s=s1=-2, and t=t1=1
Linear Diophantine Equations
• Given ax+by=c, find all possible solutions for x, and y.
• Particular solution: x0= (c/d)s and y0= (c/d)t
– Use Extended Euclidean Algorithm to get d=gcd(a,b), s, and t.
• General Solution: x=x0+k(b/d), y=y0-k(a/d) where k is an
integer (i.e. k = -∞ to +∞)
• Find the particular and general solutions to the below
given equation
• 21x+14y=35
Sol: 21x+14y=35
• Use Extended Euclidean Algorithm and get
d=gcd(21,14)=7, s=1, t=-1, a=21, b=14, c=35
• Applying particular solution
– x0= (c/d)s and y0= (c/d)t
– x0= (35/7)*1 and y0= (35/7)*(-1)
– x0= 5 and y0= -5
• General Solutions are
– x=x0+k(b/d), y=y0-k(a/d) where k is an integer
– For k=1, x = 5+1*(14/7) and y = -5-1*(21/7)
– For k=2, x = 5+2*(14/7) and y = -5-2*(21/7)
– For k=-1, x = 5+(-1)*(14/7) and y = -5-(-1)*(21/7)
– For k=-2, x = 5+(-2)*(14/7) and y = -5-(-2)*(21/7)
• Solutions are (5,-5),(7,-8),(9,-11), (1,1), …..
r1 r2 q r s1 s2 s t1 t2 t
21 14 1 7 1 0 1 0 1 -1
14 7 2 0 0 1 -2 1 -1 3
7 0 --- 1 -2 --- -1 3 ---
Example:
• Having a note of 2000, you want to change in notes 50 and 20.
what are the different combinations you will get.
• 50x+20y=2000 or 5x+2y=200
• d=gcd(50,20)=10, s=1 and t=-2
• x0= (c/d)s and y0= (c/d)t
• x0= (2000/10)*1 and y0= (2000/10)*(-2)
• X0=200 y0=-400
• x=x0+k(b/d), y=y0-k(a/d)
• K=1, (202, -405) not a valid combination
• K=-85
• 200+(20/10)k = 200+2(-85) = 30
• -400-(50/10)k = -400-5k = -400-(5*-85) = -400+425 = 25
• (30,25) one combination similarly many we can get
Modular Arithmetic

Modulo Operator

27 mod 5
36 mod 12
-18 mod 14
-7 mod 10
Set of Residues
Congruence

Meaning: 8 mod 5 = ....-2/3/13...


13 mod 10 = ............ -17/-7/3/23/ ........
23 mod 5 = ........?

23 ≡ 33 (mod 5) is true/false and also find the equivalent


series of numbers
Operations in Zn

(14+7) mod 15 in Z15


(7-11) mod 13 in Z13
(7*11) mod 20 in Z20
Example:
• (1723345+2124945) mod 11 = (8+9) mod 11 = 6
• (1723345-2124945) mod 11 = (8-9) mod 11 = 10
• (1723345*2124945) mod 11 = (8*9) mod 11 = 6
• 10n mod x = (10 mod x)n so following are true
• 10 mod 3 = 10n mod 3 = (10 mod 3)n = 1
• 10 mod 9 = 10n mod 9 = (10 mod 9)n = 1
• 10 mod 7 = 10n mod 7 = 3 (10 mod 7)n = 3n mod 7

• 2 mod 10 = 12 mod 10

• 7 mod 15 * 14mod 15 = (7*14) mod 15 = 21 mod 15 =


• (148+14432) mod 12 = 148 mod12+14432mod12=4+8 =12
Inverses
• Inverse need to find of a number relative to an operation
Generally used in cryptography:
• Additive Inverse and Multiplicative Inverse
Additive Inverse
• In Zn, two numbers a and b are Additive Inverse s of each other if
• a + b ≡ 0 (mod n) i.e (a+b) mod n = 0
• Can be calculated as b = n-a since a+b=n to have remainder 0.
• Example: Additive Inverse of 4 in Z10 is 10-4 = 6
• Find all additive inverse pairs in Z10.
• Find Additive Inverse of 14 in Z19 is:
Multiplicative Inverse
• In Zn, two numbers a and b are Multiplicative Inverse of each
other iff
• a × b ≡ 1 (mod n) i.e. (a × b) mod n = 1
Example:
• Multiplicative Inverse of 3 in Z10 is 7 since
• (3 × 7) mod 10 =1
• An integer may or may not have a Multiplicative Inverse
• An integer has a Multiplicative Inverse in Zn iff GCD(n,a)=1, i.e. a
and n are relatively prime.
• GCD(10,3)=1 so multiplicative inverse exist and the solution is 7.
• Try all combinations of Z10 Residual set {0...9}
• (3 × 0) mod 10 =0, (3 × 1) mod 10 =3, (3 × 2) mod 10 =6, (3 × 3) mod 10 =9,
(3 × 4) mod 10 =2, (3 × 5) mod 10 =5, (3 × 6) mod 10 =8, (3 × 7) mod 10 =1,
(3 × 8) mod 10 =4, (3 × 9) mod 10 =7
• Find multiplicative inverse of 8 in Z10
• Find all multiplicative inverse in Z10
• Find all multiplicative inverse in Z11

Multiplicative Inverse using Extended Euclidian Algorithm


• In Zn, two find multiplicative inverse ‘a’, With n and a given,
• s × n + t × a = GCD(n,a) = 1 if multiplicative inverse exists then
multiplicative inverse of a is the value of t mapped to Zn
Using extended Euclidean algorithm to find
multiplicative inverse
Find the multiplicative inverse of 11 in Z26.

Solution

The GCD (26, 11) is 1; the inverse of 11 is -7 or 19.


Find the inverse of 12 in Z26.

Solution

The gcd (26, 12) is 2; the inverse does not exist.


Find the multiplicative inverse of 23 in Z100.

Solution

The gcd (100, 23) is 1; the inverse of 23 is -13 or 87.


Addition and Multiplication Tables
Different Sets Zn and Zn*

Cryptography often uses two more sets: Zp and Zp*. The


modulus in these two sets is a prime number.
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:


Definitions
Operations and Relations
Determinants
Residue Matrices
Definition

A matrix of size l  m
Operations and Relations

Example of addition and subtraction.


The product of a row matrix (1 × 3) by a column matrix
(3 × 1). The result is a matrix of size 1 × 1.
Multiplication of a 2 × 3 matrix by a 3 × 4 matrix
An example of scalar multiplication
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.40
Calculating the determinant of a 2 × 2 matrix
Calculating the determinant of a 3  3 matrix
Inverses
Multiplicative inverses are only defined for square matrices.
How is matrix used in cryptography?
The key matrix is used to encrypt the messages, and its inverse is used
to decrypt the encoded messages. It is important that the key matrix be
kept secret between the message senders and intended recipients. If the
key matrix or its inverse is discovered, then all intercepted messages can
be easily decoded.
Residue Matrices:
Cryptography uses residue matrices: matrices where all elements are in Zn. A
residue matrix has a multiplicative inverse if gcd (det(A), n) = 1.
Residue Matrix A in Z26 and its multiplicative inverseA-1
Multiplying both matrices the result is multiplicative identity matrix in Z26
Example:
1 2 w.r.t Z29
A=
-1 0

Det (A) = 2 i.e. not equal to zero


GCD(detA(A),n) = GCD(2,29) = 1

You might also like