Professional Documents
Culture Documents
Chris Christensen
Class notes
Matrices
A matrix is just a rectangular array of numbers. For example,
1 2 17
1 9
3
9 , , and
3 7 , 43 0
2
7 23 9
0 6 8 23 65
9 76 1 98 10
11 7 34 72 1
The square matrix is called the coefficient matrix (a, b, c, and d are the
coefficients of the variables x and y). There are two column matrices one
consisting of the two variables and the other of the two constants that appear
on the right hand side of the system.
For the moment, we will only consider matrix multiplication of the form
square matrix column matrix
Such a multiplication is only defined if the number of columns of the square
matrix equals the number of rows of the column matrix.
The system of equations gives us the pattern for multiplication.
ax by
a b x
c d y
cx dy
The top entry of the product is calculated by, first, taking the entries of the
first row of the square matrix and multiplying them "term-by-term" with the
entries of the column matrix and then adding those products.
The lower entry of the product is calculated by, first, taking the entries of the
second row of the square matrix and multiplying them "term-by-term" with
the entries of the column matrix and then adding those products.
3 7
For example,
5 12
8 59
5 100 , and
3 7
5 12
18 68
2 114 .
g h
c
f
ax by cz
x
y dx ey fz
.
z
gx hy iz
1 0 7 5 89
For example, 3 4 9 3 81 .
12 7 5 12 141
Etc.
To multiply two square matrices of the same dimension, we just do the
multiplication one column at a time.
59 68
3 7 8 18
For example,
.
100 114
5 12 5 2
Hill's Cipher
Hill's cipher uses matrices to transform strings of plaintext letters to
ciphertext. We shall restrict ourselves to transforming digraphs.
Consider the following message:
HerbertYardleywroteTheAmericanBlackChamber.
(If the message did not consist of an even number of letters, we would place
a null at the end.)
8 59
5 100
7
22 mod 26
16
mod 26 ,
10
Deciphering
Of course, we need a procedure for deciphering this. However, just like for
the multiplicative ciphers, we cannot multiply by all matrices because we
cannot undo the multiplication for all matrices.
To go from plaintext to ciphertext in the first example above we did
3 7 8 7
5 12 5 22 mod 26
Now we want to reverse this; we want to find a matrix so that
? ? 7
? ? 22
8
mod 26
5
? ?
i.e, we want to find a matrix
so that
? ?
?
?
? 3 7
? 5 12
? ? 3 7
We want
to leave
? ? 5 12
8
8
5 5 mod 26
8
5 unchanged.
Matrix Inverse
3 7
The matrix we are looking for is called the inverse of
and is
5 12
1
3 7
denoted
.
5
12
a b
It is easy to verify that
c d
a b
The product
c d
a
c
b
ad bc
.
a
ad bc
d
ad bc
c
ad bc
d
ad bc
c
ad bc
b
ad bc
a
ad bc
a
c
b 1 0
d 0 1 which
3 7
The determinant of
is 3 12 5 7 1 1mod 26 .
5 12
3 7
3 7
So, the inverse of
is
5 12
5 12
12 19
12 7
5 3
3 mod 26 .
21
5
17
4
17
mod 26 .
9
17
5
17
4
5 12
7 23 4 23
161 92
17
mod
26
mod
26
mod 26
mod 26
115 207
9
15 25
5 23 9 23
17
Deciphering the Ciphertext
We use the inverse to decipher the first digraph of the ciphertext GV. G
corresponds to 7, and V corresponds to 22.
12 19 7 8
21 3 22 5 mod 26
h (8) e (5).
Larger Polygraphs
3 3 matrices (with inverses) can be used to encipher trigaphs. 4 4
matrices (with inverses) can be used to encipher strings of 4 letters. Etc.
Cryptanalysis
Cryptanalysis of the 2 2 Hill cipher is aided by analysis of digraph
frequencies. There are only 26 single-letter frequencies, but there are
26 26 262 676 digraph frequencies to consider. That is a lot of
frequencies to analyze doable, but a lot. 3 3 matrices would encipher
trigraphs; there are 263 17576 trigraphs to analyze. 4 4 matrices would
encipher four-letter strings; there are 264 456976 four-letter strings. 5 5
matrices would encipher five-letter strings; there are 265 11881376 fiveletter strings. Etc. Some modern encryption systems are able to encipher
one rather long message as one block.
But, before we begin thinking that we have found a perfect scheme to
encipher our messages, we should note that the Hill cipher, while interesting,
is known to be insecure. Mathematicians know much about matrices;
matrices are often used in applications of mathematics. Mathematics
courses with titles like "linear algebra" and "linear mathematics" are about
matrices. With just a little bit of background from one of these courses, it
can easily be shown that knowing only two plaintext-ciphertext digraph
correspondences allows a Hill cipher with a 2 2 key to be broken. More
generally, knowing n plaintext-ciphertext digraph correspondences allows a
Hill cipher with an n n key to be broken. (See Lewand, Robert Edward, Cryptological
Mathematics, Mathematical Association of America, 2000, pp. 128 137.)
10
Exercises
1. Multiply the following matrices, if possible.
3 6 8
1a.
.
1 4 5
3 6 2
1b.
.
1 4 3
3 6 8 2
1c.
.
1 4 5 3
3 6 2 8
1d.
.
1 4 3 5
3 5 13 1
1e. 2 7 21 3 .
9 4 1 2
3 5 13
3
1f. 2 7 21 .
5
9 4 1
1 0 11
1g.
.
0 1 23
0 0 12
1h.
.
0 0 7
11
3 7
2. Use a Hill cipher with key
to encipher the following message.
5 12
AgnesDriscollworkedforNSA.
3. The following message was enciphered with a Hill cipher with key
3 7
5 12 . Decipher the message.
ZKYZRQHBDMJMPVXWLCGFMIXGMPKBUZFHPCI
XZTIW
21 13
4e.
7 16
5. Which of the matrices in exercise 4 can be used as keys for a Hill cipher?
12
6. For each of the matrices in exercise 4 that can be used as keys for a Hill
cipher, find the inverse modulo 26.
2 7 19
2
message: unitedstates.
6
1
8
4
4
0
9
6
1
3
13