-
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
1/14
Section 2.9 The Hill Cipher; Matrices
The Hill cipher is a block or polygraphic cipher,
where groups of plaintext are enciphered as
units.
The Hill cipher enciphers data using matrix
multiplication.
We will now introduce the concept of a
matrix
-
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
2/14
Introduction to Matrices
A matrix is a rectangular array of numbers madeup of rows and columns.
The sizeof a matrix is given as m x n
m is the number of rows to the matrix. n is the number of columns to the matrix.
To indicate an individual entryin a matrix A, we use aijwhere i = row and j = column.
The general form of a mxn matrix has the formindicated here.
A square m x n matrix is a matrix where m = n. That isthe number of rows equals the number of columns
http://localhost/var/www/apps/conversion/tmp/scratch_1/The%20Size%20of%20a%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Individual%20Entries.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/General%20Form%20Of%20A%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/General%20Form%20Of%20A%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Individual%20Entries.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/The%20Size%20of%20a%20Matrix.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
3/14
Introduction to Matrices
Equality of Matrices
Two matrices A and B are equalif
They have the same size and
There corresponding entries are equal.
Special types of MatricesVectors
A row vectoris a matrix with one row.
A column vectoris a matrix with one column
http://localhost/var/www/apps/conversion/tmp/scratch_1/Equality%20of%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Vector%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Vector%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Vector%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Vector%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Equality%20of%20Matrices.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
4/14
Introduction to Matrices
Matrix Addition and Subtraction Two matrices can be added and subtracted only if they have the
same size.
Example 1: A + B and AB
Example 2: A + B and AB
Scalar Multiplication of Matrices When working with matrices, numbers are referred as scalars.
To multiply a matrix by a scalar, we multiply each entry of thematrix by the given scalar.
Example 3: 3A
Example 4: 5A2B
Addition and Scalar Multiplication Properties of Matrices
http://localhost/var/www/apps/conversion/tmp/scratch_1/Example%201%20Addition%20and%20Subtraction.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%202%20Adding%20and%20Subtracting%20Two%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%203%20Scalar%20Multiplication.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%204%205A%20-%202B.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Addition%20and%20Scalar%20Multiplication%20of%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Addition%20and%20Scalar%20Multiplication%20of%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%204%205A%20-%202B.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%203%20Scalar%20Multiplication.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%202%20Adding%20and%20Subtracting%20Two%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%201%20Addition%20and%20Subtraction.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
5/14
Introduction To Matrices
Matrix Multiplication
Multiplying two matrices requires how you multiplya row vector timesa column vector.
Example 5: Compute AB
For the matrix product AB to exist, the number of columns of A must
be equal to the number of rows of B. If A has size m x n and B has size n x p, then the product AB has size m
x p. The number of row and column vectors that must be multiplied together is
mp.
The ijth element of AB is the vector product of the ith row of A and the jthcolumn of B.
Example 6:
Example 7:
Example 8:
In general, matrix multiplication is not commutative: AB BA
http://localhost/var/www/apps/conversion/tmp/scratch_1/Multiplying%20a%20Row%20Vector%20and%20A%20Column%20Vector.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%206%20AB.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%207%20AB%20and%20BA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%208%20AB%20and%20BA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%208%20AB%20and%20BA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%207%20AB%20and%20BA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%206%20AB.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Multiplying%20a%20Row%20Vector%20and%20A%20Column%20Vector.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
6/14
Introduction to Matrices
Multiplicative Properties of Matrices
Let A, B, and C be matrices whose sizes are
multiplicatively compatible, c a scalar.
(AB)C = A(BC) matrix multiplication is associative
A(B + C) = AB + AC
(A + B)C = AC + BC
c(AB) = (cA)B = A(cB)
-
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
7/14
Introduction to Matrices
Addition Identity Matrices
The additive identity has all entries of zero. It is called thezero matrix.
If A is mxn then the zero matix is mxn.
The zero matrix is called 0.
A + 0 = 0 + A = A
Multiplicative Identity Matrices
If A is mxn then the multiplicative matrix is nxn.
The multiplicative identityhas 1s on the main diagonal(row number = column number) and 0s everywhere else.
Example 9: AI and IA
http://localhost/var/www/apps/conversion/tmp/scratch_1/Zero%20Matrices.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Multiplicative%20Identity%20Matrices.dothttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%209%20Compute%20AI%20and%20IA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%209%20Compute%20AI%20and%20IA.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Multiplicative%20Identity%20Matrices.dothttp://localhost/var/www/apps/conversion/tmp/scratch_1/Zero%20Matrices.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
8/14
Introduction to Matrices
Determinants
The determinant of a matrix is a real number.
The determinantof a 2x2 matrix.
Example 10: Find the determinant
Example 11: Find the determinant
Note: the determinant of a 1x1 matrix is just the
value of the entry. A =[3] then |A| = 3.
You can calculate the determinant of any nxn
matrix
http://localhost/var/www/apps/conversion/tmp/scratch_1/The%20Determinant%20of%20a%202x2%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2010%20Find%20the%20Determinant.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2011%20Find%20the%20Determinant.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2011%20Find%20the%20Determinant.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2010%20Find%20the%20Determinant.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/The%20Determinant%20of%20a%202x2%20Matrix.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
9/14
Introduction to Matrices
Matrix Inverses The additive inverse of a matrix is obvious. You want A + B
= 0, where B is the inverse. That is B = -A.
The more difficult to find, and not always exists, is the
multiplicative inverse. The matrix A must be nxn (a square matrix)
Notationof the inverse.
The inverse for the 2x2 matrixis fairly simple to find.
The B is the inverse of A the AB = BA = I. (I call it B here becausethis stupid program doesnt allow exponents)
Example 12: Find inverse.
Note: For the matrix A, the inverse exists if det(A) 0.
Example 13: Find Inverse.
Example 14: Find Inverse
http://localhost/var/www/apps/conversion/tmp/scratch_1/Notation%20of%20the%20Multiplicative%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Inverse%20of%202x2%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2012%20Calculate%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2013%20Calculate%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2013%20Calculate%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2012%20Calculate%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Inverse%20of%202x2%20Matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Notation%20of%20the%20Multiplicative%20Inverse.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
10/14
Introduction to Matrices
Matrices with Modular Arithmetic
For a matrix A with entries aij we way that A MOD
m is the matrix where the MOD operation is
applied to each entry: aijMOD m.
Example 15: Compute matrix MOD 26.
Example 16: Find A + B and AB MOD 5
Example 17: 3A MOD 13 Example 18: Product AB MOD 26
http://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2015%20Compute%20the%20Matrix%20Mod%2026.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2016%20A%20+%20B%20and%20A%20-%20B.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2017%203A.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2018%20Product%20AB.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2018%20Product%20AB.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2017%203A.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2016%20A%20+%20B%20and%20A%20-%20B.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2015%20Compute%20the%20Matrix%20Mod%2026.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
11/14
Introduction to Matrices
Finding the inverseof a matrix in modular
arithmetic.
Example 19: Find the inverse of a matrix
Example 20: Determine if inverse exists.
Example 21: Solve the system of equations
http://localhost/var/www/apps/conversion/tmp/scratch_1/Modular%20Matrix%20Inverse.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2019%20Find%20the%20inverse%20of%20a%20matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2020%20Determine%20if%20Inverse%20Exists.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2021%20Solve%20the%20System%20of%20Equations.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2021%20Solve%20the%20System%20of%20Equations.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2020%20Determine%20if%20Inverse%20Exists.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2019%20Find%20the%20inverse%20of%20a%20matrix.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Modular%20Matrix%20Inverse.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
12/14
The Hill System The Hill Cipher was developed by Lester Hill of Hunter
College. It requires the use of a matrix mod 26 that has aninverse. The procedure requires breaking the code up into small
segments. If the matrix is nxn, then each segment consists of nletters.
If A is the matrix and x is the n letter segment code, then theciphertext is found by calculating Ax = y. Y is the ciphertextsegment.
To decipher the text we use the inverse of the matrix A. If wecall this inverse B, then By deciphers the code returning x.
Note: It is required that the plaintext message have n letters. Ifit does not have some multiple of n letters, we pad the messagewith extra characters until it does.
Example 22: Encrypt a Message.
Example 23: Decrypt a Message
http://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2022%20Encrypt%20a%20Message.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2023%20Decrypt%20a%20Message.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2023%20Decrypt%20a%20Message.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Example%2022%20Encrypt%20a%20Message.doc -
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
13/14
Cryptanalysis of the Hill System
Having just the ciphertext when trying to crypto-analyze aHill cipher is more difficult then a monoalphabetic cipher.
The character frequencies are obscured (because we areencrypting each letter according to a sequence of letters).
When using a 2x2 matrix, we are in effect creating a 26^2 = 676character alphabet. That is, there are 676 different two lettercombinations.
If you in fact knew that the ciphertext was created using a 2x2matrix, then a crypto-analyst could break the code with bruteforce, since there are 26^4 (each entry in the matrix can have 26
different numbers) = 456976 different matrices. The way to make it more difficult is to increase the size of the
key matrix
-
8/14/2019 Chapter 2 Section 9 The Hill Cipher and Matrices.pptx
14/14
Cryptanalysis of the Hill System
If the adversary has the ciphertext and a small
amount of corresponding plaintext, then the
Hill Cipher is more vulnerable!
http://localhost/var/www/apps/conversion/tmp/scratch_1/Cryptanalysis%20of%20the%20Hill%20System.dochttp://localhost/var/www/apps/conversion/tmp/scratch_1/Cryptanalysis%20of%20the%20Hill%20System.doc