The Theorem that Won the War: Part 1 – Enigma on Paper

Author(s): 
Jeff Suzuki (Brooklyn College)

 

In 1923, the firm of German engineer Arthur Scherbius (1878–1929) began selling a machine that could encrypt messages automatically. Marketed as Enigma, it was soon adopted (and adapted) by the German military, and by the outbreak of World War II, it was used for almost all important German military communications.

To understand the mathematics behind Enigma, it helps to have an Enigma machine. Unfortunately, most of the remaining machines are in museums, whose curators don’t take too kindly to handling their exhibits, so we’ll have to make do with a mockup. Online Enigma emulators are available, but to understand the mathematical details, we’ll set up a simple “paper” Enigma to analyze key points. We will do this in two parts, pausing to take part in some specific activities along the way.

Enigma machine in use during the Battle of France.
Figure 3.
Enigma machine in use in a radio tank
during the Battle of France in May 1940.
Wikimedia Commons. CC BY-SA 3.0 de.

 

 

Display of Enigma machines at National Cryptology Museum, US.
Figure 4. A display of Enigma machines and paraphernalia exhibited at the U.S. National Cryptologic Museum.
Left side of display: Enigma machines from 1923 to 1939. Right side of display: Enigma machines from 1939 to 1945.
Photographs by Robert Malmgren. Creative Commons Attribution-Share Alike 3.0 Unported.

 

The Theorem that Won the War: Part 1.1 – Rotors

Author(s): 
Jeff Suzuki (Brooklyn College)

 

Mechanically, an Enigma machine consisted of a set of encryption drums or rotors. The rotors have contact points on each side, joined by wires. It’s convenient to think of these contact points as representing letters, with the wiring joining two letters of the alphabet. When an operator pressed a letter, an electrical current flowed between the contacts, lighting up the encrypted version of the letter.

For our paper Engima, we’ll consider a six letter alphabet: \(a, b, c, d, e, f\). A “side” view of a rotor might look like the following (the different line styles have no significance, and they are only used to make it easier to distinguish between connections):


Figure 5. Side view of a rotor. All diagrams in
this article were created by the author.

In the diagram in Figure 5, the left-side \(a\) is connected to the right-side \(b\); the left-side \(b\) is connected to to the right-side \(c\); and so on.

Before we can describe this mathematically, we need to make a decision: Since electrical current can flow along a wire in either direction, we must choose a direction, either left-to-right or right-to-left.  For example, if current is flowing from left to right, then the (left side) \(a\) is connected to the (right side) \(b\). Consequently, if the operator pressed \(a\), the current would light up \(b\), which would be the encrypted version.  We might write this as \(a \rightarrow b\).

We can compile all of these left-to-right encryptions in tabular form as
\[\left(\begin{array}{cccccc} a & b&c &d &e &f \\ \downarrow &\downarrow &\downarrow &\downarrow &\downarrow &\downarrow \\b&c&f &e&d &a \end{array}\right)\]

Mathematically, we've taken the letters in the order \(a, b, c, d, e, f\), and rearranged them as \(b, c, f, e, d, a\). This is an example of what mathematicians call a permutation.

If we omit the down arrows and enclose everything in parentheses, we can represent our encryption in Cauchy two-line notation:
\[\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&c&f &e&d &a \end{array}\right)\]

Perhaps surprisingly to readers familiar with Stigler’s law of eponymy, Cauchy two-line notation is named after its inventor, Augustin-Louis Cauchy (1789–1857); you can read his original 1815 publication (en Français) here.

What if our current ran from right to left?  In that case, we can represent our permutation as \[\left(\begin{array}{cccccc} a & b&c &d &e &f \\ f&a&b &e&d &c \end{array}\right)\]

 

To explore the basics of rotor design and permutations further, continue to the Activities for Part 1.1 (Rotors).

Return to the overview of Part 1 (Enigma on Paper).

Skip to the overview of Part 1.2 (The Enigma Encryption).

 

The Theorem that Won the War: Activities for Part 1.1 (Rotors)

Author(s): 
Jeff Suzuki (Brooklyn College)

 

  1. Suppose a rotor has the wiring shown:

    Rotor diagram for an exercise on the Enigma machine.

    1. Describe the permutation if the current is running from left to right.
    2. Describe the permutation if the current is running from right to left.
    3. What do you notice about the two permutations?
  2. Draw the side view of a rotor whose right-to-left permutation is given. Then give the left-to-right permutation for the rotor.
    1. \(\left(\begin{array}{cccccc} a & b&c &d &e &f \\ d&f&b&a&c &e \end{array}\right)\)
    2. \(\left(\begin{array}{cccccc} a & b&c &d &e &f \\ c&e&d&a&f &b \end{array}\right)\)
  3. Consider a permutation described as \(\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&e&d&c&f &a \end{array}\right)\).
    1. Explain why it is reasonable to say \(\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&e&d&c&f &a \end{array}\right)=\left(\begin{array}{cccccc} a & f&d &b &e &c \\ b&a&e&c&d &f \end{array}\right)\).
       

      Suggestion: “Things that do the same thing are the same thing.”
      We can view a permutation as a function, so the permutation on the left maps a → b, d → e, and so on;
      what does the permutation on the right do?

    2. Rewrite the permutation shown by completing the second row: \[\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&e&d&c&f &a \end{array}\right)=\left(\begin{array}{cccccc}  & & & & & \\ a&b&c&d&e &f \end{array}\right)\]
    3. Rewrite the permutation shown by completing the first row: \[\left(\begin{array}{cccccc} a & d&e &b &c &f \\ b&e&d&c&f &a \end{array}\right)=\left(\begin{array}{cccccc}  & & & & & \\ a&b&c&d&e &f \end{array}\right)\]
  4. Consider the permutation \(\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&a&e&c&d&f \end{array}\right)\).
    1. Draw a rotor corresponding to this permutation. (Assume this permutation is for a left-to-right flow of current.)
    2. Find the right-to-left permutation.
    3. Find the first row of the permutation on the right: \[\left(\begin{array}{cccccc} a & b&c &d &e &f \\ b&a&e&c&d &f \end{array}\right)=\left(\begin{array}{cccccc}  & & & & & \\ a&b&c&d&e &f \end{array}\right)\]
    4. Compare the permutations you found in Activity 4b with Activity 4c. Does this suggest an easy way to find the right-to-left permutation from the left-to-right permutation?

 

Return to the overview of Part 1.1 (Rotors).

Continue to the overview of Part 1.2 (The Enigma Encryption).

 

 

The Theorem that Won the War: Part 1.2 – The Enigma Encryption

Author(s): 
Jeff Suzuki (Brooklyn College)

 

To encrypt a message, an Enigma operator typed it into a keyboard. When a key was pressed, an electrical signal would pass through a plugboard \(S\); through a sequence of rotors \(R_{1}\), \(R_{2}\), \(R_{3}\); then through a reflector \(Q\) that would send the signal back through the rotors in the reverse order, and then through the plugboard, lighting up the encrypted version of the letter. We can represent this process as encrypting the original plaintext letter \(p\) as the encrypted ciphertext letter \(c\).

Diagram showing encryption of original plaintext letter p as encrypted ciphertext letter c.
Figure 6. Diagram of Enigma encryption process,
beginning with the plaintext letter \(p\) and ending with the ciphertext letter \(c\).

To create the paper Enigma, you’ll need to cut out a set of encryption rotors; a template appears here. For convenience and tractability, we’ll omit the plugboard and use just a single rotor and the reflector; we’ll also reduce our alphabet to six letters \(a\), \(b\), \(c\), \(d\), \(e\), \(f\). These omissions do not substantially alter the process used by the Poles to break Enigma.

Our paper Enigma will require two types of rotors: a “keyboard” rotor and a “reflector” rotor. To prepare a keyboard rotor, draw one-way arrows from one vertex to another. Each vertex should have a unique “outgoing” arrow and a unique “incoming” arrow. Figure 7 below shows some “forbidden” setups and one allowable one. (Note that while you can do a “return” path so that two vertices are connected to each other, it’s discouraged because it’s less interesting.)

Diagrams of various allowable and forbidden “keyboard” rotors.
Figure 7. Diagrams of various allowable and forbidden “keyboard” rotors.

The reflector rotor is constructed in almost the same way, but this time our arrows are bidirectional and simply join vertices. Again, every vertex must have one and only one connection. The primary problem faced and solved by the Poles was determining the internal wirings of the reflector and the rotor. For our examples, we’ll use the reflector and keyboard rotor in Figure 8.

Diagram of sample reflector and keyboard rotors for Enigma machine.
Figure 8. Diagrams of sample reflector and keyboard rotors.

To make a paper Enigma, set the reflector rotor into the “Reflector” circle and the keyboard rotor into the “Keyboard” circle in the paper Enigma available here. It will help to pin the rotors down through the hole in the center. As a check to make sure you are ready to follow along with the examples below, your initial setup should look something like that shown in Figure 9 below (the dashed line has no significance and is only there to make the process easier to follow).

Diagram showing initial setup for an Enigma machine encrpytion example.
Figure 9. Initial setup of reflector and keyboard rotors.

In general, a letter will be encrypted by sending it through the keyboard rotor; then the reflector; and then “backwards” through the keyboard rotor.

For example, if we pressed \(a\), then:

  • The keyboard rotor would send \(a\) to \(c\),
  • The reflector rotor would send \(c\) to \(a\),
  • The keyboard rotor would send \(a\) backwards to \(d\).

Thus this setup would encrypt \(a\) as \(d\).

Used this way, Enigma would have been a simple substitution cipher and would have been trivial to break. So the actual Enigma machine incorporated one more feature that vastly compounded the difficulty: every time a key was pressed, the keyboard rotor would advance one place.[2] 

As an example, let’s encrypt the word \(cab\). When we press the first letter \(c\), the keyboard rotor will advance one place, which we’ll take to be a counterclockwise rotation. Thus the encryption of the first letter would use the setup shown in Figure 10.

Diagram of initial set up of reflector and keyboard rotors for an Enigma maching encryption example.
Figure 10. Setup for encryption of first letter.

To encrypt the first letter (\(c\)), we’ll send it through the keyboard rotor, the reflector, then “backwards” through the keyboard rotor:

  • The keyboard rotor sends \(c\) to \(f\),
  • The reflector rotor sends \(f\) to \(e\),
  • The keyboard rotor sends \(e\) backwards to \(d\).

So \(c\) is encrypted as \(d\).

Now for the second letter (\(a\)). Again, pressing the key advances the keyboard rotor one place, so the encryption will be based on the configuration in Figure 11.

Diagram showing setup for encryption of first letter in an Enigma machine example.
Figure 11. Setup for encryption of second letter.

To encrypt the second letter of our message (\(a\)):

  • The keyboard rotor sends \(a\) to \(b\),
  • The reflector sends \(b\) to \(d\),
  • The keyboard rotor sends \(d\) backwards to \(b\).

So \(a\) is encrypted as \(b\).

Finally, for the third letter, our rotor shifts one place, as shown in Figure 12.


Diagram showing setup for encryption of first letter in an Enigma machine example.
Figure 12. Setup for encryption of third letter.

Our encrpytion of \(b\) will be:

  • The keyboard sends \(b\) to \(c\),
  • The reflector sends \(c\) to \(a\),
  • The keyboard sends \(a\) backwards to \(f\).

So \(b\) would be encrypted as \(f\). Thus the word \(cab\) would be encrypted as \(dbf\).

To explore the basics of rotor design and permutations further, continue to the Activities for Part 1.2 (Encryption).

Return to the overview of Part 1 (Enigma on Paper).

Skip to the overview of Part 2 (The Algebra of Enigma).


[2] The second and third rotors on the actual Enigma would also advance one place for every full turn of the preceding rotor.

 

The Theorem that Won the War: Activities for Part 1.2 (Encryption)

Author(s): 
Jeff Suzuki (Brooklyn College)

 

Suggestion: The encryption activities are easier if they are done as group activities, with one person calling out the keyboard encryptions and the other the reflector encryptions.

For activities 1–4 in this section, we continue with the example from the previous page, for which the "Initial Setup" was as follows:

Diagram of initial setup of reflector and keyboard rotors for some exercises on Enigma machine encryption.

  1. Consider the initial setup shown above.
    1. Draw a rotor corresponding to the keyboard rotor.
    2. Explain why, when the current is moving right-to-left, we use the encryption \(a \rightarrow c\), but when the current is moving left-to-right, we use the backward encryption \(a \rightarrow d\).
  2. Express, in Cauchy two-line notation, the permutation used for the first; second; and third letters in the encryption of the message \(cab\) that we completed on the previous page using the initial setup shown above.
  3. Suppose we want to send the message \(cab \, bad\) using the initial setup shown above. Complete the encryption. Ignore the space, so that the \(b\) of \(bad\) will be the fourth letter that needs to be encrypted.
  4. An encryption system is not useful unless the recipients can decrypt the messages. Suppose you receive the encrypted message \(dbf\).
    1. “Reset” the paper Enigma to the initial setup shown above. Then encrypt \(dbf\). What do you notice?
    2. Continue on with the rest of your encrypted version of the message \(cab \, bad\). What happens?
  5. Notice that the initial placement of the rotors is arbitrary.  Suppose the initial setup of the rotors is as shown below:

     

    Diagram of initial setup of reflector and keyboard rotors for an exercise on Enigma machine encryption.

    1. Encrypt the word \(cab\) using this initial setup.
    2. Express, in Cauchy two-line notation, the encryption used for the first; second; and third letters.
  6. Now suppose your initial setup is:

     

    /sites/default/files/images/upload_library/46/Suzuki_Enigma/Suzuki_Ex5_Act1_2.jpg

    1. Use this initial setup to encrypt the message: \(faded \, cab\).
    2. Verify that using the same initial setup will decrypt the message correctly.
  7. Explain why it is impossible for any rotor and reflector set to encrypt a letter as itself.

Return to the overview of Part 1.2 (The Enigma Encryption).

Continue to the overview of Part 2 (The Algebra of Enigma).