6.2 Hill Ciphers

This section is not needed for understanding the rest of the chapter. It is included as an example of a block cipher.

In this section, we discuss the Hill cipher, which is a block cipher invented in 1929 by Lester Hill. It seems never to have been used much in practice. Its significance is that it was perhaps the first time that algebraic methods (linear algebra, modular arithmetic) were used in cryptography in an essential way. As we’ll see in later chapters, algebraic methods now occupy a central position in the subject.

Choose an integer n, for example n=3. The key is an n×n matrix M whose entries are integers mod 26. For example, let

M=1234561198.

The message is written as a series of row vectors. For example, if the message is abc, we change this to the single row vector (0, 1, 2). To encrypt, multiply the vector by the matrix (traditionally, the matrix appears on the right in the multiplication; multiplying on the left would yield a similar theory) and reduce mod 26:

(0,  1,  2)(1234561198)(0,  23,  22)(mod 26).

Therefore, the ciphertext is AXW. (The fact that the first letter a remained unchanged is a random occurrence; it is not a defect of the method.)

In order to decrypt, we need the determinant of M to satisfy

gcd(det(M), 26)=1.

This means that there is a matrix N with integer entries such that MNI (mod 26), where I is the n×n identity matrix.

In our example, det(M)=3. The inverse of M is

13141133425619133.

Since 17 is the inverse of 3 mod 26, we replace 1/3 by 17 and reduce mod 26 to obtain

N=22516172415131.

The reader can check that MNI (mod 26).

For more on finding inverses of matrices mod n, see Section 3.8. See also Example 15 in the Computer Appendices.

The decryption is accomplished by multiplying by N, as follows:

(0,  23,  22)(22516172415131)(0,  1,  2)(mod26)

In the general method with an n×n matrix, break the plaintext into blocks of n characters and change each block to a vector of n integers between 0 and 25 using a=0, b=1, , z=25. For example, with the matrix M as above, suppose our plaintext is

blockcipher.

This becomes (we add an x to fill the last space)

111142102815741723.

Now multiply each vector by M, reduce the answer mod 26, and change back to letters:

(1, 11, 14)M=(199, 183, 181)(17, 1, 25)(mod26)=RBZ(2, 10, 2)M=(64, 72, 82)(12, 20, 4)(mod26)=MUE, etc.

In our case, the ciphertext is

RBZMUEPYONOM.

It is easy to see that changing one letter of plaintext will usually change n letters of ciphertext. For example, if block is changed to clock, the first three letters of ciphertext change from RBZ to SDC. This makes frequency counts less effective, though they are not impossible when n is small. The frequencies of two-letter combinations, called digrams, and three-letter combinations, trigrams, have been computed. Beyond that, the number of combinations becomes too large (though tabulating the results for certain common combinations would not be difficult). Also, the frequencies of combinations are so low that it is hard to get meaningful data without a very large amount of text.

Now that we have the ciphertext, how do we decrypt? Simply break the ciphertext into blocks of length n, change each to a vector, and multiply on the right by the inverse matrix N. In our example, we have

RBZ=(17, 1, 25)(17, 1, 25)N=(755, 427, 66)(1, 11, 14)=blo, 

and similarly for the remainder of the ciphertext.

For another example, see Example 21 in the Computer Appendices.

The Hill cipher is difficult to decrypt using only the ciphertext, but it succumbs easily to a known plaintext attack. If we do not know n, we can try various values until we find the right one. So suppose n is known. If we have n of the blocks of plaintext of size n, then we can use the plaintext and the corresponding ciphertext to obtain a matrix equation for M (or for N, which might be more useful). For example, suppose we know that n=2 and we have the plaintext

howareyoutoday=71422017424142019143024

corresponding to the ciphertext

ZWSENIUSPLJVEU=252218413820181511921420

The first two blocks yield the matrix equation

714220abcd2522184(mod 26).

Unfortunately, the matrix 714220 has determinant 308, which is not invertible mod 26 (though this matrix could be used to reduce greatly the number of choices for the encryption matrix). Therefore, we replace the last row of the equation, for example, by the fifth block to obtain

7142019abcd25221511(mod 26).

In this case, the matrix 7142019 is invertible mod 26:

714201915101821(mod 26).

We obtain

M5101821252215111512113(mod 26).

Because the Hill cipher is vulnerable to this attack, it cannot be regarded as being very strong.

A chosen plaintext attack proceeds by the same strategy, but is a little faster. Again, if you do not know n, try various possibilities until one works. So suppose n is known. Choose the first block of plaintext to be baaa=1000, the second to be abaa=0100, and continue through the nth block being aaab=0001. The blocks of ciphertext will be the rows of the matrix M.

For a chosen ciphertext attack, use the same strategy as for chosen plaintext, where the choices now represent ciphertext. The resulting plaintext will be the rows of the inverse matrix N.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.35.81