CNS-2
CNS-2
Cryptography-I
a=q×n
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
Note
Note
Answer: 3
Note
• In modular arithmetic, an integer may or may
not have a multiplicative inverse.
• When it has, the product of the integer and its
multiplicative inverse is congruent to 1 modulo n.
Examples
Example 1
Find the multiplicative inverse of 7 and 8 in Z10.
Multiplicative inverse of 7 is 3, but 8 has no
multiplicative inverse.
Note: gcd can help us to quickly find out whether a given number
has multiplicative inverse or not.
gcd(10,7)=1=> 7 has multiplicative inverse in modulo 10
gcd (10, 8) = 2 ≠ 1 => 8 has no multiplicative inverse in modulo 10
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 3
Note
• The Extended Euclidean algorithm(EEA) 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.
Note
• We need to use Zn when additive inverses are
needed
• We need to use Zn* when multiplicative
inverses are needed.
Two More Sets
Scalar multiplication
Inverse of a Square matrix
Note
a b
For A= ,
c d
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.
Example
Find the inverse of a matrix 7 3
mod 26
1 2
12 21
The inverse of the given matrix mod 26
7 3