Mathematics Of: Cryptography-I

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 59

Mathematics of

Cryptography-I

Bhagwat Prasad Chaudhury


Dept. of CSE
Silicon Institute of Technology
Set of Integers and Integer Division

In integer arithmetic, if we divide a by n, we can


get q and r .
Answer the following Question

• When we use a computer or a calculator, r and q are


negative when a is negative.
• How can we make r positive?

-255=(-23 x 11) + (-2)


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

If a is not zero and we let r = 0 in the division


relation, we get

a=q×n

If the remainder is zero, n a


If the remainder is not zero, n a
Example: Divisibility

a. The integer 5 divides the integer 30 because


30 = 6 × 5. So, we can write 5 30

b. The number 8 42 because 42 = 5 × 8 + 2 has


a remainder of 2.
Properties: Divisibility

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|(m × b + n × c), where m
and n are arbitrary integers
Continued
Example

Answer the followings:

a. Given 3|15 and 15|45, Can we say 3|45?

b. Given 3|15 and 3|9, Can we say 3|66?


Facts:Divisibility

Fact 1: The integer 1 has only one


divisor, itself.

Fact 2: Any positive integer has at least


two divisors, 1 and itself (but it
can have more).
Common divisors of two integers
Greatest Common Divisor

The greatest common divisor of two


positive integers is the largest integer
that can divide both integers.

Euclidean Algorithm

Fact 1: gcd (a, 0) = a


Fact 2: gcd (a, b) = gcd (b, r), where r is
the remainder of dividing a by b
Finding GCD(a,b) by using Euclidean Algo.
Continued
Example
Find the greatest common divisor of 2740 and 1760.
Solution
We have gcd (2740, 1760) = 20.
Continued
Example
Find the greatest common divisor of 25 and 60.
Solution:
We have gcd (25, 60) = 5.
Extended Euclidean Algorithm (EEA)

Given two integers a and b, we often need to


find other two integers, s and t, such that

This equation is also called Bezout’s identity or


Bezout’s Lemma. s and t are called Bezout’s coeffi-
cients for (a,b).
The Extended Euclidean Algorithm can be used
to calculate the gcd (a, b) and the values of s and
t.
Continued
Extended Euclidean algorithm(The process)
Continued
Extended Euclidean algorithm
Continued
Example
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.
Continued
Example

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

Out of two outputs q and r in integer


division, we are interested in only one of
the outputs, i.e. r in modular arithmetic, .
Topics we will discuss this section:
1. Modulo Operator
2. Set of Residues
3. Congruence
4. Operations in Zn
5. Addition and Multiplication Tables
6. Different Sets
Modulo Operator

• The modulo operator is shown as mod.


• The second input (n) is called the modulus.
• The output r is called the residue.
Continued
Example
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
d. Dividing −7 by 10 results in r = −7. After
adding the modulus to −7, r = 3.
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.
Congruence

To show that two integers are congruent, we use the


congruence operator ( ≡ ). For example, we write:
Concept of congruence relationship
Residue Classes

A residue class [a] or [a]n is the set of integers


congruent modulo n.
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. Figure Binary operations in Z
n
Zn: Examples
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.
Zn: Properties
Continued
Figure Properties of mod operator
Continued
Examples
 (1,723,345 + 2,124,945) mod 11
= (8 + 9) mod 11 = 6
 (1,723,345 − 2,124,945) mod 11
= (8 − 9) mod 11 = 10
 (1,723,345 × 2,124,945) mod 11
= (8 × 9) mod 11 = 6
Continued
Example

Compute the followings:

1012 mod 3 = 1
1050 mod 7 = 350 mod 7
54 mod 7 = 2
Inverses

• In modular arithmetic, we often need to find


the inverse of a number relative to an
operation.
• It can be an additive inverse (relative to an
addition operation) or a multiplicative inverse
(relative to a multiplication operation).
Additive Inverse

In Zn, two numbers a and b are additive inverses


of each other if

Note

In modular arithmetic, each integer has


an additive inverse. The sum of an
integer and its additive inverse is
congruent to 0 modulo n.
Continued
Example

Find all additive inverse pairs in Z10.

The six pairs of additive inverses are (0, 0), (1,


9), (2, 8), (3, 7), (4, 6), and (5, 5).
Multiplicative Inverse

In Zn, two numbers a and b are the multiplicative


inverse of each other if

Note

In modular arithmetic, an integer may or


may not have a multiplicative inverse.
When it does, the product of the integer
and its multiplicative inverse is
congruent to 1 modulo n.
Continued

Example 1
Find the multiplicative inverse of 8 in Z10.
There is no multiplicative inverse because gcd (10, 8) =
2 ≠ 1. In other words, we cannot find any number
between 0 and 9 such that when multiplied by 8, the
result is congruent to 1.
Example 2

Find all multiplicative inverses in Z10.


There are only three pairs: (1, 1), (3, 7) and (9, 9). The
numbers 0, 2, 4, 5, 6, and 8 do not have a multiplicative
inverse.
Continued
Example
Find all multiplicative inverse pairs in Z11.

We have seven pairs: (1, 1), (2, 6), (3, 4), (5, 9), (7, 8),
(9, 5), and (10, 10).
How to find out Multiplicative Inverse
of BIG Number?

Note

The Extended Euclidean algorithm finds


the multiplicative inverses of b in Zn
when n and b are given and
gcd (n, b) = 1.
The multiplicative inverse of b is the
value of t after being mapped to Zn.
Using Extended Euclidean algorithm to
find Multiplicative inverse
Continued
Example
Find the multiplicative inverse of 11 in Z26.

The gcd (26, 11) is 1; the inverse of 11 is 7 or


19.
Continued
Example
Find the inverse of 12 in Z26.

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


Zn and Zn*

Note

We need to use Zn when additive


inverses are needed; we need to use Zn*
when multiplicative inverses are needed.
Two More Sets

• Cryptography often uses two more sets:


• Zp and Zp*.
• The modulus in these two sets is a prime
number.
What are the uses of Additive and
Multiplicative inverses ?
 When a sender uses a key for encryption, he
may choose an integer from the set Zn or Zn*
depending on the algorithms used.
 If he chooses from Zn, the receiver has to find
the additive inverse of that integer for getting
the key for decryption.
 Similar logic applies for multiplicative inverse
in Zn*.
MATRICES

• Matrices are widely used in Cryptography.


• A matrix is a linear array of l x m elements.
Examples of matrices
Operations and Relations
Example

Addition and Subtraction


Continued
Example

Multiplication of a row matrix by a column matrix


Continued
Example

Multiplication of a 2 × 3 matrix by a 3 × 4 matrix


Continued
Example

Scalar multiplication
Inverse

The inverse of a matrix A , denoted as A-1


should hold the following relation:
A A-1 =I,
where I is the identity matrix

Note

Multiplicative inverses are only defined


for square matrices.
Inverse(Continued)

a b
For  A = ,
c d 

the inverse can be found by using the formula:

1 1  d b  1  d b 
A     
det A  c a  ad  bc  c a 
Residue Matrix and Inverse

• Cryptography uses residue matrices.

• Matrices where all elements are in Zn.

• A residue matrix has a multiplicative


inverse if gcd (det(A), n) = 1.
LINEAR CONGRUENCE

Cryptography often involves solving an equation


or a set of equations of one or more variables
with coefficients in Zn.

Methods to solve :
1 Single-Variable Linear Equations
2 Set of Linear Equations
Single-Variable Linear Equations

Equations of the form ax ≡ b (mod n ) might have no


solution or a limited number of solutions.

Steps to find out the solutions if d divides b


1. Reduce the equation by dividing both sides by d.
2. Multiply both sides by the multiplicative inverse of
reduced ‘a’ to find the particular solution x0.
Continued

Example 1
Solve the equation 10 x ≡ 2(mod 15).
First we find the gcd (10 and 15) = 5. Since 5 does not
divide 2, we have no solution.

Example 2
Solve the equation 14 x ≡ 12 (mod 18).
Continued
Example

Solve the equation 3x + 4 ≡ 6 (mod 13).


• First we change the equation to the form ax ≡ b (mod n).
• We add −4 (the additive inverse of 4) to both sides, which
give 3x ≡ 2 (mod 13).
• Because gcd (3, 13) = 1, the equation has only one
solution, which is x0 = (2 × 3−1) mod 13 = 18 mod 13 = 5.
• We can see that the answer satisfies the original equation:

3 × 5 + 4 ≡ 6 (mod 13).
Set of Linear Equations
We can also solve a set of linear equations with
the same modulus if the matrix formed from the
coefficients of the variables is invertible.
Continued

Example
Solve the set of following three equations:

15 14 11
16 5 0
1 11 9
A-1
The result is x ≡ 15 (mod 16), y ≡ 4 (mod 16), and z ≡
14 (mod 16).

You might also like