Hill Ciphers 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Table 1:21 the Substitution22 23 Table24 For25 the Hill26 Cipher27 28
Total Page:16
File Type:pdf, Size:1020Kb
This means we have 29 characters with which to write our plaintext. These have been shown in Table 1, where the 29 characters have been numbered from 0 to 28. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . __ ? Hill Ciphers 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Table 1:21 The substitution22 23 table24 for25 the Hill26 Cipher27 28 Let us apply this to an example of a Hill 2-cipher corresponding to the substitution scheme shown in Table 1 with 29 characters. Let the key be the 2 × 2 matrix 14 techspace �푎 � 29 Jonaki B Ghosh GO We can also refer to E as the encoding matrix. We will use E to encipher groups of two consecutive Introduction characters. Suppose we have to encipher the word . The alphabets G and O correspond to the numbers 6 and 14, respectively from our substitution table. We represent it by a 2 × 1 matrix. Cryptography is the science of making and breaking codes. It is 6 푎 � the practice and study of techniques for secure communication. GO 14 Modern cryptography intersects the disciplines of mathematics, computer science, and electrical engineering. Applications of To encipher , we pre-multiply this matrix by the encoding matrix E. cryptography include ATM cards, computer passwords, and Hill Cipher 14 6 62 e-commerce. In this article we explore an interesting 푎 �푎 �푎 � 29 14 138 cryptography method known as the , based on matrices. We explore the method using the spreadsheet MS Excel The product is a 2 × 1 matrix with entries 62 and 138. But what characters do the numbers 62 and 138 to perform operations on matrices. Hill Ciphers represent? These are not in our substitution table! What we do is as follows: We divide these numbers by 29 and consider their respective remainders after the division process is done. Thus when we divide 62 by 29, themodular remainder arithmetic is 4 and when we divide 138 by 29, the remainder is 22. plaintextHill ciphers are an application of matrices to cryptography. Ciphers are methods for transforming a given message, the To express this in the language of , we write: ciphertext, into a new form unintelligible to anyone who does not know the key – the transformation used to convert the plaintext 62 ≡ 4 ( 29 138 ≡ 22 ( 29 to the . The inverse key is requiredencipher to reverse the transformation to recover the original message. To use the key to Equivalence and residues modulo an integer transform plaintextdecipher into ciphertext is to the plaintext. De�inition � modulus To use the inverse key to transform the ciphertext back into congruent modulo m plaintext is to the ciphertext. : Given an integer 1, called the , we say that the two integers and are modular arithmetic. to one another if is an integral multiple of . To denote this, we write: In order to understand Hill ciphers, we must �irst understand �e�inition � Hill n-cipher ≡ . We read this as: ‘ is congruent to modulo ’. :A has for its key a given matrix whose entries are non-negative integers from the set In other words, ≡ means that for some integer which could be positive, {0, 1, 2, 3, … , 1, where is the number of characters negative or zero. used for the encoding process. Suppose we wish to use all 26 For our cipher, we have: 62 ≡ 4 29 and 138 ≡ 22 29. Note: 62 4 2 × 29, or alphabets from A to Z and three more characters, say ‘.’, ‘-‘ and ‘?’. 62 4 2 × 29, and 138 22 4×29, or 138 22 4 × 29. GO EW The numbers 4 and 22 correspond to the letters E and W respectively from our substitution table. Thus, the word is enciphered to ! 6160 At Right Angles | Vol. 3, No. 3, November 2014 Vol. 3, No. 3, November 2014 | At Right Angles 6160 2 At Right Angles ∣ Vol. 3, No. 3, November 2014 This means we have 29 characters with which to write our plaintext. These have been shown in Table 1, where the 29 characters have been numbered from 0 to 28. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . __ ? 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20Table 1:21 The substitution22 23 table24 for25 the Hill26 Cipher27 28 Let us apply this to an example of a Hill 2-cipher corresponding to the substitution scheme shown in Table 1 with 29 characters. Let the key be the 2 × 2 matrix 14 �푎 � 29 GO We can also refer to E as the encoding matrix. We will use E to encipher groups of two consecutive characters. Suppose we have to encipher the word . The alphabets G and O correspond to the numbers 6 and 14, respectively from our substitution table. We represent it by a 2 × 1 matrix. 6 푎 � GO 14 To encipher , we pre-multiply this matrix by the encoding matrix E. 14 6 62 푎 �푎 �푎 � 29 14 138 The product is a 2 × 1 matrix with entries 62 and 138. But what characters do the numbers 62 and 138 represent? These are not in our substitution table! What we do is as follows: We divide these numbers by 29 and consider their respective remainders after the division process is done. Thus when we divide 62 by 29, themodular remainder arithmetic is 4 and when we divide 138 by 29, the remainder is 22. To express this in the language of , we write: 62 ≡ 4 ( 29 138 ≡ 22 ( 29 Equivalence and residues modulo an integer De�inition � modulus congruent modulo m : Given an integer 1, called the , we say that the two integers and are to one another if is an integral multiple of . To denote this, we write: ≡ . We read this as: ‘ is congruent to modulo ’. In other words, ≡ means that for some integer which could be positive, negative or zero. For our cipher, we have: 62 ≡ 4 29 and 138 ≡ 22 29. Note: 62 4 2 × 29, or 62 4 2 × 29, and 138 22 4×29, or 138 22 4 × 29. GO EW The numbers 4 and 22 correspond to the letters E and W respectively from our substitution table. Thus, the word is enciphered to ! 61 At Right Angles | Vol. 3, No. 3, November 2014 Vol. 3, No. 3, November 2014 | At Right Angles 61 2 At Right Angles ∣ Vol. 3, No. 3, November 2014 GO Note EW EW In order to use this method of sending secret messages, the sender has to encrypt the plaintext and : In case the message has an odd number of characters, a full stop or underscore (a ‘.’ ‘ or a ‘_’) may be send the encrypted form. This meansEW the sender sends instead. The receiver gets the message . added at the end to complete the pair. For example, if the plaintext is “LET_US_GO”, then we have 9 The secret key, that is, the encoding matrix E is known only to the sender and the receiver. Now let us see characters. So we add a ‘.’ at the end to make the message “LET_US_GO.” how the receiver deciphers what EWstands for. Each pair will form a column of a 2×6matrix (as there are 6 pairs). Let us call this matrix P (the In order to decipher the message , we begin by looking for the numbers corresponding to E and W in plaintext matrix) our substitution table. These are 4 and 22 respectively. We represent this in the form of a 2 ×1matrix 12 19 27 18 5 13 ��� � 4 Step 3: 0 7 8 27 20 26 � � 22 Compute the product EP �� 9 −4 We pre-multiply this matrix by the inverse of the matrix E, that is, by E = � �. So: −2 1 14 12 19 27 18 5 13 12 47 59 126 85 117 �� � � �� ��� � 29 0 7 8 27 20 26 24 101 126 279 190 260 �� 9 −4 4 −52 �� �� �� � −2 1 22 14 In order to perform this computation in Excel we proceed as follows We need another de�inition. Note that any arbitrary integer can be divided by to yield a quotient Enter the 2×2matrix E and the 2×6matrix P as separate arrays as shown. Each entry of a matrix may �e�initionand remainder � ; that is, . Then we say . residue of a modulo m be entered by typing a number in a cell and pressing Enter. The arrow keys may be used to move to the next appropriate cell. : Let be any integer exceeding 1. For an arbitrary integer , the is the unique integer in the set {0, 1, 2, 3, … , −1 such that . Thus: 23 7 , since 23 2×7. Here 23, and 7. What about negative integers? For example, what is when −1 and ? Clearly has to be an integer between 0 and 7. Note that −1−3 × 6. Thus 6and we can write −16 . Now coming back to deciphering our Hill cipher, we need to �ind for −52 and 14 for 29. Note that −52 −2 × 29 6 and 14 0 × 29 14.Thus: −52 6 29 and 14 14 29. −52 6 Thus we may write � �� � 29 14 14 EW GO Isn’t this great! 6 represents G and 14 represents O from our substitution table. Hence we have deciphered to obtain the original characters or the plaintext! 14 Let us now see how to encipher a longer message or plaintext using the key � �.