# Chaocipher

The Chaocipher is a cipher method invented by John Francis Byrne in 1918 and described in his 1953 autobiographical Silent Years. He believed Chaocipher was simple, yet unbreakable. Byrne stated that the machine he used to encipher his messages could be fitted into a cigar box. He offered cash rewards for anyone who could solve it.
Byrne tried unsuccessfully to interest the US Signal Corps and Navy in his system. Although numerous students of classical cryptanalysis attempted to solve the challenge messages over the years, none succeeded. For 90 years, the Chaocipher algorithm was a closely guarded secret known only to a handful of persons.
In May 2010 Byrne's daughter-in-law, Patricia Byrne, donated all Chaocipher-related papers and artifacts to the National Cryptologic Museum in Ft. Meade, Maryland, USA. This led to the disclosure of the Chaocipher algorithm.

## Design

In Byrne's embodiment of Chaocipher, the system consists of two disks, referred to as the left and right disks, each having 26 equal-sized removable tabs around its periphery. These removable tabs contain the 26 letters of the alphabet (i.e., A through Z) in some prearranged order. On the circumference of each disk are studs that allow the two disks to 'engage' or interlock. When engaged, turning one disk in one direction (e.g., clockwise) will cause the other wheel to turn in the opposite direction (e.g., counterclockwise). The tabs are removable, meaning that a tab can be removed from the periphery, another block of tabs shifted, and the extracted tab inserted into an empty space in the periphery.
At any point in time, the disks can be engaged with each other so that moving one moves the other in the opposite direction. Similarly, engaged disks can be disengaged, at which point a disk can be turned without moving the other disk. Engagement and disengagement could conceivably be performed by placing a lever in one of two positions.
The two disks mentioned above sit on a platform consisting of two spindles.
On the platform around each disk are two marks known as the 'zenith' and the 'nadir'. The zenith can be thought of as 12 o'clock on an analog clock, while the nadir is 6 o'clock.

## Operation

In its classic form, the Chaocipher system consists of two alphabets, with the right-side alphabet used for locating the plaintext letter, while the other ("left") alphabet is used for reading the corresponding ciphertext letter. The underlying algorithm is related to the concept of dynamic substitution whereby the two alphabets are slightly modified after each input plaintext letter is enciphered. This leads to nonlinear and highly diffused alphabets as encryption progresses.
Deciphering is identical to enciphering, with the ciphertext letter being located in the "left" alphabet while the corresponding plaintext letter is read from the "right" alphabet.
A detailed description of the Chaocipher algorithm is available as well as discussions of the deciphered plaintexts and the solution to Byrne's challenge.

### Overview of the encryption process

Given left and right disks, enciphering a plaintext character consists of five steps:
* Verify the left and right disks are engaged.
* Rotate the plain (right) disk, bringing the desired plaintext letter to the zenith position.
* Read the corresponding ciphertext letter at the zenith position on the cipher (left) disk.
* Permute the left disk.
* Permute the right disk.
These five steps are performed continuously until the plaintext input is exhausted. To illustrate the process we will encipher the first plaintext letter of Byrne's Exhibit 1 using the same alphabets and disk setting he used, as shown in Figure 1.

### How to Encipher Plaintext
#### Locate the plaintext letter

Suppose we want to encipher the letter "A". Locate 'A' on the periphery of the plaintext (right) disk. You can see the plaintext letter highlighted in Figure 2.
While the disks are engaged, rotate the right disk to bring the plaintext letter 'A' to the zenith (Figure 3). Note how the left (cipher) disk rotates respectively in the opposite direction.
The letter in the zenith position on the cipher (left) disk is our ciphertext letter (i.e., 'C').
At this point we have completed the enciphering of a plaintext letter into ciphertext, i.e. 'A' (pt) was enciphered into 'C' (ct).
See the next section for instructions on performing Chaocipher's unique permuting of the two disks in preparation for enciphering the next plaintext letter.

### Permuting the alphabets

Now that the plaintext letter and its corresponding ciphertext letter are known, proceed to permute the alphabets on both disks in preparation for enciphering the next plaintext letter.

#### Permute the left wheel

Permuting the left wheel's alphabet involves the following general steps (Figure 4):
* Physically extract the letter tab found at position zenith-1 (i.e., one counter-clockwise position past the zenith) taking it out of the disk's alphabet, temporarily leaving an unfilled 'hole'.
* Shift all letter tabs in positions zenith-2 (advancing counter-clockwise) down to and including the nadir (zenith-13), moving them in unison one position clockwise. This will close the current 'hole', leaving a new 'hole' at the nadir position.
* Insert the previously extracted letter tab into the empty nadir position.
Before performing the permuting step, the left disk should look like the diagram in Figure 4a.
Performing step (1), extract the letter at position zenith-1 (i.e., "P") leaving a momentary 'hole' at that position (Figure 4b).
For step (2) shift all letters in the counter-clockwise sequence beginning with zenith-2 ("E") down to and including the nadir ("O"), moving the sequence ("EDQRSTIXYLMO") as a complete block one position clockwise (Figure 4c).
In the final step (3), insert the extracted letter ("P") back into the alphabet at the nadir position. The left is now permuted and should now look like Figure 4d.

#### Permute the right wheel

Permuting the right disk is similar to that of the left disk, with small but significant differences. It consists of the following general steps (Figure 5):
* Disengage the two disks, rotate the right disk one position counter-clockwise (i.e., the current letter at the zenith should rotate to position zenith-1), and reengage the two disks.
* Physically extract the letter tab now found at position zenith+2 (i.e., two clockwise positions past the zenith) taking it out of the disk's alphabet, leaving a temporarily unfilled 'hole'.
* Shift all letter tabs in positions zenith+3 down to and including the nadir (zenith+13), sliding them in unison one position counter-clockwise. This will close the current 'hole', leaving a new 'hole' at the nadir position.
* Insert the previously extracted letter tab into the empty nadir position.
Let's perform the above steps on the right disk using our example. The right disk should look like the diagram in Figure 5a. In this configuration the letter at the zenith is 'A'.
In step (1) first disengage the two disks. This allows rotating the right disk (see next step) without moving the left disk. Next, rotate the disk one position counter-clockwise, moving the letter 'Y' to the zenith position (Figure 5b). Lastly, reengage the two disks.
In step (2) extract the letter tab at position zenith+2 ('N') from the disk, temporarily leaving a 'hole' (Figure 5c).
In step (3) slide the eleven letter tabs from zenith+3 until zenith+13 (i.e., 'BQDSEFGHLWI') one position counter-clockwise. This closes up the 'hole' at zenith-2 while opening a new 'hole' at the nadir (Figure 5d).
For the final step ( 4) insert the previously extracted letter tab ("N") back into the disk at the nadir position. This completes permuting the right disk, which should now look like Figure 5e.
Reengaging the disks prepares the system for enciphering the next plaintext letter (Figure 6).

### How to decrypt ciphertext

Deciphering a Chaocipher-encrypted message is identical to the steps used for enciphering. The sole difference is that the decipherer locates the known ciphertext letter in the left (cipher) disk, reading off the plaintext letter from the right (plain) disk. Left/right disk permuting is identical in enciphering and deciphering.

## Points of interest
### Henry E. Langen discussed Chaocipher with John F. Byrne

Henry E. Langen, editor of The American Cryptogram Association's newsletter The Cryptogram between 1952–1956, was quoted as saying "He did explain that the machine is made up somewhat like a typewriter with two revolving disks with the alphabets arranged along the periphery in a complete disorder [...] With only two disks used, I am a bit confused as to how this can result in such utter chaotification of the plaintext message."

### Who knew how Chaocipher worked?

Although John F. Byrne presented Chaocipher challenge messages in his autobiographical "Silent Years", he never described how the system worked. Anyone tackling the challenge messages had to do so with no knowledge of the system.
Until 2010 at least three people knew how it worked: Byrne's son John, and two of the editors of Cryptologia to whom John confided the underlying method in 1990 (i.e., Lou Kruh and Cipher Deavours).
In August 2009, Moshe Rubin located Byrne's daughter-in-law Patricia Byrne (nee Neway) who, in May 2010, donated her father-in-law's Chaocipher artifacts and papers to the National Cryptologic Museum.