# The Alice cipher.

Lewis Carroll loved ciphers. Between 1858 and 1868 he invented four and recorded them in his diary: two matrix ciphers and two polyalphabetic ciphers: the Telegraph Cipher and the Alphabet Cipher. He submitted the latter two for publication, and personally used them to write letters to his child friends.

It is possible to view Carroll's novel Through the Looking-Glass and What Alice Found There as Carroll's fifth cipher. The plot follows Alice across a chess board in her journey to become a queen, and Carroll helpfully provides a chess board with pieces placed on it and a list of chess moves at the beginning of the book. The story, board, list of moves, and Martin Gardner's annotations comprise the elements necessary to a cipher: a plaintext, a key, and a ciphertext.

Cipher Basics

A plaintext is the original message being sent. A classic, military-esque example would be "ATTACK AT DAWN." In order to prevent unintended recipients from reading this message, the plaintext is encrypted using a key which transforms the letters into something unreadable e.g. BUUBDLBUEBXO. In Through the Looking-Glass, the plaintext can be found in the starting chess board placed at the beginning of the book.

A cipher key is the method used to encode a plaintext and decode a ciphertext. In the simplest of substitution ciphers, the key is nothing more than a shift in the alphabet where A=B, B=C, C=D, and so on; resulting in achart which looks like this:
```
ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
```

This cipher, knownas the Caesar Cipher, is easy to both use and break. To add securitytomessages, steps are added to the key, and in more complicated ciphers,the key can consist of multiple steps involving key phrases,modulararithmetic, and so on.

In ThroughtheLooking-Glass, the key may be found in the list of moves beneath the chess board andin Gardner's annotations. The first is the process which turnsthe chess board into a story. The second helps provide necessaryknowledge of how to interpret the moves, i.e. what happens where andwhen. Together, the moves and annotations relate the story to thechessboard; which is what a key does for a plaintext and aciphertext.

Finally, the ciphertext in Through the Looking Glass is the story itself. While the story contains elements of chess inthecharacters and references, the actual plot only vaguely resembles a gameof chess. This partly due to Carroll's artistic licensewithtraditional chess rules, but this is also because Carroll translatedthechess board into the Looking-Glass world. One example of this iswhenAlice-the-chess-pawn moves forward one square on the chessboard,Alice-in-the-story crosses a stream.

Having identifiedtheelements of a cipher in Carroll's novel, my goal was to combineit with elements of his other ciphers to create a new, Alicethemedcipher.

Carrol'sCiphers

Carroll's formal ciphers, outlined in two paperspublished by Francine Ables and Stanley H. Lipson, consist oftwopolyalphabetic ciphers and two matrix ciphers.

The firstofCarroll's polyalphabetic ciphers, which he named "TheAlphabet Cipher," is a kind of Vigenere cipher, and usesthe following table:

Polyalphabetic Cipher Table

To usea Vigenere cipher, a key word is used (e.g. ALICE) and isthenrepeated over the plaintext:

Key: A L I C E A L I C E AL

Plain: A T T A C K A T D A W N

To encrypt thefirst letter of the plaintext, an A, fred the column for the keyphraseletter 'A' in 'ALICE' on the top of the gridand the row for the plaintext letter A in 'ATTACK' on theleft side of the grid. The intersection of the two 'A's isA, which means that the first letter of the ciphertextis'A'.

The second letter of the plaintext is T.The second letter of the key phrase is L. The L column and T rowintersect at E. Therefore, the second letter of the encrypted phraseisE.

The entire plaintext ATTACKATDAWN encoded with key wordALICE is AEB CGKLB FEWY.

To decipher, the letter of the keyphrase becomes the column, the letter of the ciphertext becomestheintersection, and the plaintext is the letter of the row.

Thesecond of Carroll's polyalphabetic ciphers, called"TheTelegraph Cipher," is a "kind of Beaufort Cipher. It usesthe same table as a Vigenere Cipher, but is applieddifferently.Rather than starting from the top column and left row and findingtheencrypted letter where the column and row intersect, a Beaufort cipherbegins with the key letter as the top column, travels down the columnuntil the plaintext letter is found, then travels left out of the rowand is enciphered as the letter of the row. In short, it is the sameprocess as the decryption of the previous cipher.

Using thesame key phrase 'ALICE' and the sameplaintext'ATTACKATDAWN' with a Beaufort Cipher yields a ciphertextof AILXYKPLBWWC.

To decode, the key phrase letter is thecolumn, the ciphertext letter is the row, and the plaintext letter isthe intersection.

Carroll's matrix ciphers usethefollowing table:

Thismatrix uses the Latin alphabet, which means that I and J are substitutedfor each other, as are V and U. The asterisk fills in the remainingspace to create an even grid of 5x5. Each letter is assigned a twodigitnumerical value of (column, row) so that the letters of our key phrasebecome A=(00), L=(20), I=(13), C=(02), and E=(04):00.20.13.02.04.

In the first of Carroll's matrix ciphers, the distanceismeasured between the key phrase letter and the plaintext letter, andthat distance becomes the new ciphertext letter. For example, the firstkey phrase letter is A, the first plaintext letter is A, and A is 0 rowsand 0 columns away from A, so the first letter/number of the ciphertextis A=00. The second key phrase letter is L. The second plaintext letteris T. T is 1 column and 3 rows away from L, so the second letter/numberis I=13.

Using this method, theplaintext'ATTACKATDAWN' with key phrase 'ALICE' isencoded as AILQQXQLBFWC or as00.13.02.03.03.14.03.02.01.10.40.02.

To decode, use the letter of the key phrase, then add the distance(the double digit number in the ciphertext) and you have the plaintextletter again. So L is 0 columns away and 2 rows up from the N at the endof DAWN.

The second matrix cipher uses the same matrix table,but a different method of encryption. 'ALICE' isstillequivalent to 00.20.13.02.04, but this time the plaintext is alsoconverted into numerical terms using the samemethod:00.33.33.11.02.14.00.33.03.00.40.22. To convert the plaintext tociphertext using a key, the value of the key phrase letter is subtractedfrom the value of the plaintext letter:
``` 00.33
33.11.02.14.00.33.03
00.40.22.
-00.20.13.02.04.00.20.13.02.04.00.20.
00.13.20.14.03.00.30.20.01.10.40.02.
```

To decode,the ciphertext is added to the key phrase; the reverse process.

It is important to note that the math taking place ismodular,specifically mod4. I find it helpful to think of the graph aswrappingaround, with the bottom edge meeting the top edge and the left edgemeeting the right edge. When converting from letters to numbers, numbersto letters, or measuring the distance from one letter to another (inthefirst cipher), we always move down the column and across the row from left to right. When we run out of numbers, we start again atthetop of the column and the left side of the row. This is the equivalent of adding: always going forward, topto bottom, left to right.

However, in the second matrixcipher, the numbers are subtracted. To subtract using the matrix,columns are traveled bottom to top and rows are traveled right to left. In short, we are going backwards on the graph. So to subtract 04 from02, find 02 on the grid then travel 0 columns left and four rows up.

Application to Through TheLookingGlass

The cipher usedinThrough the Looking Glass contains structural elements similar to all of Carroll'sfourciphers. When compared to the two matrix ciphers, the chess board itselfis easily recognizable as a kind of matrix, and instead of movingaccording to mod4 addition and subtraction, Carroll provides a seriesofchess moves to guide us around the board. When compared to thepolyalphabetic ciphers, the chess board can serve as the table ofshifted alphabets.

Using these recognizable elements, Icreated the following table:

Rather than the 26x26 grid of the potyalphabetic cipher, or the 5x5grid of the matrix cipher, I have used the 8x8 grid of the chessboardCarroll provided at the beginning of the book, and labeled itusingmod7.

Also, rather than using a repeated or modifiedalphabet, I have chosen to fill my matrix with words used in variouspoems throughout the book. This is a reasonable choice because mymatrixstill contains the necessary information for a key phrase, plaintext,and ciphertext. Also, while decreasing the amount of safety offered bythe anonymity of the alphabet, I have decreased the amount of timenecessary to code/decode a ciphertext to something more suitable for aclass period.

For my key phrase I have chosen theline'THAT SUMMERS EVENING LONG A-GO', a slight variation onthe second to last line of the White Knight's poem found inChapter 8. For my plaintext I have chosen the sixth verse of the poemwhich ends the book:
```In
a
Wonderland they lie, Dreaming as the days
go
by, Dreaming as the summers
die:
```

To encode using Carroll's originalalgorithm (the list of chess moves) I have combined moves where thechess board remains static, and made the amended list of moves readasfollows:

1, Alice meets R.Q.

2. R.Q. toK.R's 4th

3. Alice through Q's 3rd(by railway) to Q's 4th (Tweedledum andTweedledee)

4. W.Q. to Q.B's 4th; Alice meets W.Q

5.W.Q. to Q.B's 5th (becomes sheep)

6. Alice to Q's 5th (shop,river,shop)

7. W.Q. to K. B's 8th (leaves eggonshelf)

8. Alice to Q's 6th(HumptyDumpty)

9. W.Q. to Q.B's 8th (flying fromR.Kt.)

10. Alice to Q's 7th(forest)

11. R. Kt. to K's 2nd (ch.)

12. W. Kt.takes R. Kt.; W. Kt. to K. B's 5th

13. Alice toQ's 8th (coronation)

14. R.Q. to K'ssq.(examination); Alice becomes Queen; Queen's castle; AliceCastles(feast)

15. W.Q. to Q.R's 6th(soup)

16. Alice takes R.Q. & wins

When encodedusing mod7 coordinates, the squares where each move ends readasfollows:

36.73.34.24.23.33.50.32.20.31.41.53.30.40.03.65.

This is not strictly equivalent to the Beaufort andVigenere ciphers because the algorithm also doubles as the keyphrase. However, because the input-output of the system has thesamestraightforward characteristics of those two ciphers, actually using thelist of chess moves to encode/decode feels fairly similar to usingtheBeaufort and Vigenere ciphers.

Carroll'smatrixciphers may be applied on the Alice Cipher Matrix without modificationof either. The key phrase is encrypted asfollows:

17.03.07.77.73.31.

Using Carroll's first matrixcipher to measure the distance between the key phrase and theplaintextyields the followingciphertext:

26.70.35.43.30.02.41.73.21.42.56.22.21.45.04.76.

Converted to words, the ciphertext reads as follows:

GYRE SENT TOWN KINGS AS MIMSY BY A GIMBLE FISH BROWN CABBAGESGIMBLE BRILLIG ALL WINGS

Using Carroll's secondmatrixcipher of key phrase-plaintext=ciphertext yields thefollowing:

71.10.53.53.50.06.47.51.67.46.32.66.67.43.04.12.

Converted to words, the ciphertext reads:

TO SHOESDREAMING DREAMING AS PLUM-CAKE HOT SHIPS TOVES RATHS THE BOILENG TOVESKINGS ALL TOLD

Any combination of words could be used inthematrix. Of course, the words themselves will give a connotation ofthegeneral subject of the plaintext, as demonstrated by the easilyidentifiable words "mimsy," "slithy,"and"brillig" which denote work by or relating toLewisCarroll.

References

Abeles, F. & Lipson, S.H. (1990). The Matrix Cipher of C. L. Dodgson. Cryptologia,XTV (1), 28-36.

Abeles, F. & Lipson, S. H. (1990). SomeVictorian Periodic Polyalphabetic Ciphers. Cryptologia,XIV(2), 128-134.

Beaufort Cipher. (n.d.).InWikipedia. Retrieved April 22, 2013fromhttp://en.wikipedia.org/wiki/Beaufort_cipher

Carroll, L.(2000). The Annotated Alice: The Definitive Edition (Gardner, M., Ed.). New York, NY: W.W. Norton & Company,Inc.

Modular Arithmetic. (n.d.).InWikipedia. Retrieved April 22, 2013fromhttp://en.wikipedia.org/wiki/Modular_arithmetic

Vigenere Cipher. (n.d.). In Wikipedia. Retrieved April 22, 2013fromhttp://en.wikipedia.org/wiki/Vigenre_cipher

ASHLEYDALE

New Palestine, Indiana