3

I am attempting a to simulate an 'Enigma M3' machine. As I understand it, the M3 is internally wired as:

Name ABCDEFGHIJKLMNOPQRSTUVWXYZ Notch
I EKMFLGDQVZNTOWYHXUSPAIBRCJ Y
II AJDKSIRUXBLHWTMCQGZNPYFVOE M
III BDFHJLCPRTXVZNYEIWGAKMUSQO D
UKW-B YRUHQSLDPXNGOKMIEBFZCWVJAT

NOTE: I've only included the definitions for the wheels used in this example. As I understand it, the first 3 wheels are the same as the ones used in the Enigma I to enable backwards compatibility.

Given the machine settings:

Name Setting
Wheel Order I II III
Reflector UKW-B
Ring Settings A A A
Wheel Positions A A A

In this configuration, this simulator gives me:

Keyboard Input:       A
Rotors Position:      AAB
Plugboard Encryption: A
Wheel 3 Encryption:   C
Wheel 2 Encryption:   D
Wheel 1 Encryption:   F
Reflector Encryption: S
Wheel 1 Encryption:   S
Wheel 2 Encryption:   E
Wheel 3 Encryption:   B
Plugboard Encryption: B
Output (Lampboard):   B

In my simulator, the following happens:

  • The rightmost wheel (III) advances by one, nets AAB
  • Running A through wheel III at position B nets D instead of C.

The full operation in my simulator:

Operation Result
III D
II K
I N
UKW-B K
I B
II J
III U

What am I doing wrong? Do I have an incorrect definition for wheel III? The above definition of wheel III specifies D in the second space, so D make sense in this context, but appears to be incorrect.

References:

RQDQ
  • 131
  • 4
  • I would suggest to get Enigma I working first before venture into M3. Rotors VI, VII and VIII have two turnover positions. They are Z-A and M-N. – Chan Tai Man Jan 24 '24 at 17:35

2 Answers2

2

Looks like you've misunderstood what happens to the permutation implemented by a rotor when it rotates. If a rotor which does permutation $\pi$ rotates through one step, the permutation it implements changes to the conjugate $p^{-1}\pi p$ of $\pi$ by the alphabet cycle $p = (A, B, C, \ldots, Z)$.

When rotor III has rotated once, its permutation becomes the conjugate of the one you've given by $p$, so it will send $A \stackrel{p}{\mapsto} B \stackrel{\pi}\to D \stackrel{p^{-1}}\mapsto C$. This is then fed to rotor II which sends C to D, and so on.

You might find this Enigma simulator written in Python, by Brian Neal useful for testing your simulator - generating test cases programatically with that should be a lot easier than running an online simulator "by hand". As far as I know Brian Neal's code is accurate.

2

Rotors are I, II and III. Rings and indicator settings are at their home positions. Reflector is UKW-B. Suppose $E_0$ is an Enigma I machine without a plugboard; at $t=0$, $n_{\text{indicator}}=1$, i.e. $\texttt{A}$. See footnote. Suppose $E_1$ is the same at $t=1$. We have $E_1 = (\rho^nR\rho^{-n})MLUL^{-1}M^{-1}(\rho^nR^{-1}\rho^{-n})$, where,

$n=n_{\text{indicator}} - n_{\text{ring}} = 1$ (an integer mod 26 in $\mathbb{Z}_{26}$) with $n_{\text{indicator}}=2$, i.e. $\texttt{B}$ and $n_{\text{ring}} = 1$, i.e. $\texttt{01}$;

since $\rho^1 = \rho = \begin{pmatrix} \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathtt{BCDEFGHIJKLMNOPQRSTUVWXYZA} \end{pmatrix}$,

$\rho^{-1} = \begin{pmatrix} \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathtt{ZABCDEFGHIJKLMNOPQRSTUVWXY} \end{pmatrix}$ and

$R = \begin{pmatrix} \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \\ \mathtt{BDFHJLCPRTXVZNYEIWGAKMUSQO} \end{pmatrix} = \mathtt{(CFLVMZOYQIRWUKXSG)(ABDHPEJT)(N)}$,

we have $\rho R \rho^{-1} = \texttt{(BEKULYNXPHQVTJWRF)(ACGODISZ)(M)}$;

$M = \mathtt{(FIXVYOMW)(CDKLHUP)(ESZ)(BJ)(GR)(NT)(A)(Q)}$;

$L = \mathtt{(AELTPHQXRU)(BKNW)(CMOY)(DFG)(IV)(JZ)(S)}$; and

$U = \mathtt{(AY)(BR)(CU)(DH)(EQ)(FS)(GL)(IP)(JX)(KN)(MO)(TZ)(VW)}$.

Therefore, $E_1 = \texttt{(AB)(CQ)(DM)(EF)(GX)(HI)(JS)(KW)(LP)(NY)(OT)(RV)(UZ)}$.

For example, we can obtain $(\texttt{A})E_1 = \texttt{B}$ from the above expression or via the following diagram.

                B                  A
                ^                  |
                |                  v
rho R rho^-1 = (BEKULYNXPHQVTJWRF)(ACGODISZ)(M)
                 ^                  |
                 |                  |
                 +-----------------+|
                                   ||
                          +--------++
                          |        |
                          v        |
    M        = (FIXVYOMW)(CDKLHUP)(ESZ)(BJ)(GR)(NT)(A)(Q)
                           |        ^
                           |        |
                           |        +----------------+
                           +------------+            |
                                        |            |
                                        v            |
    L        = (AELTPHQXRU)(BKNW)(CMOY)(DFG)(IV)(JZ)(S)
                                         |           ^
                                    +----+           |
                                    |+---------------+
                                    v|
    U        = (AY)(BR)(CU)(DH)(EQ)(FS)(GL)(IP)(JX)(KN)(MO)(TZ)(VW)

Q.E.D.

Footnote: Indicators $\textbf{n}_{\text{indicator}} = (k_{\text{indicator}}, j_{\text{indicator}}, n_{\text{indicator}})$, rings $\textbf{n}_{\text{ring}} = (k_{\text{ring}}, j_{\text{ring}}, n_{\text{ring}})$, and wiring core offsets = $(k, j, n) = \textbf{n}_{\text{indicator}} - \textbf{n}_{\text{ring}}$ where $k, j, n \in \mathbb{Z}_{26} = \{1, 2, \cdots, 25, 0\}$.

$k_{\text{indicator}}, j_{\text{indicator}}, n_{\text{indicator}} \in \mathbb{A} = \{\mathtt{A}, \mathtt{B}, \cdots, \mathtt{Z}\} \cong \mathbb{Z}_{26}$ and $k_{\text{ring}}, j_{\text{ring}}, n_{\text{ring}} \in \mathbb{B} = \{\mathtt{01}, \mathtt{02}, \cdots, \mathtt{26}\} \cong \mathbb{Z}_{26}$.

P.S. It possibly is not very helpful to keep track of notch positions, which are 8 places ahead of the turnover positions. It is better to use Royal Flags Wave Kings Above or Q-R E-F V-W J-K Z-A.

P.P.S. Expanding the right rotor (III) computation of which you might not be very sure. Turnover position is at V-W. Therefore, there is no middle wheel turnover (mwto) and indicators are $\texttt{AAB}$. $\rho, \rho^{-1}, R$ are elements of a permutation group. For clarity, write $\rho, \rho^{-1}$ in double row notation and $R$ in cycle notation. The latter has three orbits. Their lengths are 17, 8 and 1 respectively.

          AB
          |^
          ||
          v|
rho    = (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
          BCDEFGHIJKLMNOPQRSTUVWXYZA
          |^
          ||
          ++------------------+
           |                  |
          ++                  |
          |                   v
R      = (CFLVMZOYQIRWUKXSG)(ABDHPEJT)(N)
           ^                   |
           |                   |
           +---+               |
               |               |
             +-+---------------+
             | |
             | |
             v |
rho^-1 = (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
          ZABCDEFGHIJKLMNOPQRSTUVWXY
             | ^
             v |
             C E
Chan Tai Man
  • 157
  • 8