Lecture 9

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Cryptography

Cryptography is the study of writing in secret code that goes back to ancient times. Modern
cryptography intersects the disciplines of mathematics, computer science, and engineering.

Applications of cryptography include

 ATM cards
 Computer passwords
 and electronic commerce.

More precisely study of encoding and decoding of secret message is called cryptography.

Here we will use some terms:

 Cipher text: coded messages are called cipher text(CT).


 Plaintext: encoded messages are called plaintext and is denoted by PT.
 Enciphering: the process of converting from plain text to cipher text is called
enciphering, also known as encoding.
 Deciphering: the reverse process of converting from cipher text to plain text is called
deciphering, also known as decoding.

The simplest ciphers, called substitution ciphers, are those that replace each letter of the
alphabet by a different letter. For example, in the substitution cipher

Plain A BCD EFGHI J KLMNOPQRS T UVWXYZ

Cipher D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

the plaintext letter A is replaced by D, the plaintext letter B by E, and so forth. With this
cipher the plaintext message

for example: NEED HELP becomes QHHG KHOS

ROME WAS NOT BUILT IN A DAY

Becomes

URPH ZDV QRW EX LOW LQ D GDB

A disadvantage of substitution ciphers is that it is relatively easy to break the code by


statistical methods.

One method of encryption using linear algebra, specifically matrix operations, we call Hill
ciphers. The method involves two matrices: one to encode, the encoding matrix, and one
to decode, the decoding matrix (usually inverse of encoding matrix).

Before exploring further such a method, we should have basic knowledge of


1. Matrix multiplication
2. Inverse of a matrix
3. Modular arithmetic

Modular Arithmetic: In modular arithmetic we are given a positive integer 𝑛,


called the modulus and any two integers whose difference is an integer multiple of
the modulus, are regarded as “equal” or “equivalent” with respect to the modulus 𝑛.
More precisely, we have

Definition: If n is a positive integer and a and b are any integers, then we say that a
is equivalent to b modulo n, written as 𝑎 ≡ 𝑏 (𝑚𝑜𝑑 𝑛), If 𝑎 − 𝑏 is an integer
multiple of n.

For example: 7 ≡ 2 (𝑚𝑜𝑑 5) here dividing 7 by 5 we have 2 remainder

19 ≡ 1 (𝑚𝑜𝑑 2) here dividing 19 by 2 we have 1 remainder

−1 ≡ 25 (𝑚𝑜𝑑 26)

12 ≡ 0 (𝑚𝑜𝑑 6)

−64 ≡ ? (𝑚𝑜𝑑 26)

Hill Ciphers

First, the characters in the original message or stream are assigned numerical values. For
the purposes of this document, A-Z are represented by the numbers 1-26 (26 ≡ 0).

The encoding matrix can be generated using any integers that the user desires. It can be
something as simple as a 2x2 or 3x3 matrix composed of random integers. The matrix must
be invertible for use in decoding.
A B CD E F G H I J K L M N O P Q R S T U V W X Y Z
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26=0

3 3
Example 1. Use the key matrix K= [ ], to obtain the Hill cipher from the plain
2 5
text “HELP”.
Solution: Step 1. Group successive plaintext letters into pairs and replace each
plaintext letter by its numerical value. Here from the above table
𝐻 →8
𝐸→5
𝐿 → 12
𝑃 → 16
Firstly, we will do work for HE and then we will do for LP.
Step 2
𝐻
convert each plaintext pair into a column vector 𝑃 = [ ] plaintext vector.
𝐸
8
Replacing each letter by its numerical value 𝑃 = [ ]
5
Using formula for ciphertext vector
3 3 8 24 + 15
𝐶 = 𝐾𝑃(𝑚𝑜𝑑26) = [ ][ ] = [ ]=
2 5 5 16 + 25
39 (𝑚𝑜𝑑26) 13
=[ ] = [ ] (how)
41 15
Now again from the table of Hill Ciphers
13 𝑀
[ ] = [ ] ciphertext vector.
15 𝑂
Step 3
Now we work for LP
using numerical values of alphabets for the pair LP,
𝐿 12
𝑃 = [ ] implies 𝑃 = [ ]
𝑃 16
3 3 12 84 6
𝐶 = 𝐾𝑃(𝑚𝑜𝑑 26) = [ ] [ ] (𝑚𝑜𝑑26) = [ ] (𝑚𝑜𝑑 26) = [ ]
2 5 16 104 0
Now
6 𝐹
[ ] = [ ] ciphertext vector.
0 𝑍
Hence, combining the ciphertext vectors the entire ciphertext message is MOFZ.
Example 2

1 2 13 29 3
[ ][ ] = [ ] = [ ] = 𝐶 𝑋
0 3 8 24 24
Because the plaintext was grouped in pairs and enciphered by a 2×2 matrix, the Hill
cipher in Example 1, 2 is referred to as a Hill 2-cipher. It is obviously also possible
to group the plaintext in triples and encipher by a 3×3matrix with integer entries;
this is called a Hill 3-cipher. In general, for a Hill n-cipher, plaintext is grouped into
sets of n letters and enciphered by an 𝑛 × 𝑛 matrix with integer entries.
Example 3
Encode the message TO GIVE
1 2 0
using 𝐾 = [0 1 2]
0 1 1

Solution: Step 1
T O G I V E
20 15 7 9 22 5
Group successive plaintext letters numerical values into 3x1 size vectors, as given
coding matrix is of 3x3 size. Here we have combined the step 2 and 3 as
20 9
X= [15 22]
7 5
Product KX will generate the coded message
1 2 0 20 9
KX=[0 1 2] [15 22]
0 1 1 7 5
20 + 30 + 0 9 + 44 + 0 50 53 24 1
= [0 + 15 + 14 0 + 22 + 10] = [29 32] (𝑚𝑜𝑑 26)= [ 3 6]
0 + 15 + 7 0 + 22 + 5 22 27 22 1
Hence, the entire ciphertext message is XCVAFA.
Work to do
1 3
Q1. Encode the message DARK NIGHT using key matrix [ ].
2 1
1 2
Q2. Use the matrix [ ] to obtain Hill-Cipher from the plain text ATTACK.
0 3
1 2 4
Q3. Encode the message TIME UP using 𝐾 = [0 −1 2 ]
0 1 −1

You might also like