Deterministic Enigma Simulator

2025-11-10

The Enigma machine is often treated as a mysterious black box β€” press a key, get a letter, and trust that something complex happened inside.

This project takes the opposite approach.

It implements a deterministic, inspectable Enigma simulator, where every transformation is visible, reproducible, and explainable. Nothing is randomized, nothing is hidden, and nothing depends on trust.

If you know the configuration and the input sequence, the output is guaranteed to be identical β€” every time.


🧠 How Enigma Worked (In Real Life)

Enigma was not random. It was a stateful electromechanical machine whose security relied on configuration complexity rather than unpredictability.

Given the same machine state and the same sequence of key presses, it always produced the same output.

Core Components

A standard WWII Enigma (M3) consisted of:

  1. Keyboard – Each key closed a circuit for one letter
  2. Plugboard (Steckerbrett) – Optional letter swaps before and after encryption
  3. Rotors – Rotating substitution wheels with internal wirings and notches
  4. Reflector – Redirected the signal back through the rotors
  5. Lampboard – Displayed the output letter

βš™οΈ The Signal Path (Real Enigma)

The electrical signal followed a fixed path:

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  Lampboard  β”‚
                 β””β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Plugboard    β”‚
                β””β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Rotor Iβ”‚ Rotor II    β”‚ Rotor IIIβ”‚
        β”‚  (L)   β”‚   (M)       β”‚   (R)    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
                   β”‚Reflector β”‚
                   β””β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”˜
                        β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Rotor Iβ”‚ Rotor II    β”‚ Rotor IIIβ”‚
        β”‚  (L)   β”‚   (M)       β”‚   (R)    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Plugboard    β”‚
                β””β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                 β”‚   Keyboard  β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The reflector ensures the signal always returns, making Enigma self-inverse: the same settings encrypt and decrypt.


πŸ” Rotor Stepping and State

Each key press advanced the internal state:

  • The rightmost rotor steps every key press
  • A rotor at its notch advances the rotor to its left
  • This produces the double-stepping anomaly

As a result, even repeated letters encrypt differently.


πŸ” Why Enigma Was Considered Secure

Enigma’s strength came from its vast configuration space:

  • rotor selection and order
  • starting positions
  • ring settings
  • plugboard wiring

The algorithm itself was never secret β€” only the configuration was.

Because the system was deterministic, once the configuration was known, all outputs were predictable β€” which ultimately enabled cryptanalysis.


🧩 How This Simulator Models Enigma

This simulator models Enigma as it actually was:

  • historically accurate rotor wirings (I–V)
  • correct notch-based stepping
  • double-stepping behavior
  • plugboard substitution (up to 10 pairs)
  • reflector B and C
  • forward and backward signal traversal

No randomness. No shortcuts.


βš™οΈ Machine Configuration (JSON)

A complete machine state is represented as JSON:

{
  "rotors": [
    { "id": "I", "position": "A", "ring": 1 },
    { "id": "II", "position": "C", "ring": 1 },
    { "id": "III", "position": "C", "ring": 1 }
  ],
  "reflector": "B",
  "plugboard": ["AB", "CD", "OP"]
}

This corresponds directly to a real Enigma key sheet.

The configuration is:

  • exportable
  • downloadable
  • importable
  • sufficient to recreate the machine exactly

🧠 Signal Trace (Explainability)

For any key press, the simulator can expose the full signal path:

Plugboard IN : A β†’ R
Rotor III    : R β†’ X (pos B)
Rotor II     : X β†’ M (pos A)
Rotor I      : M β†’ Q (pos A)
Reflector    : Q β†’ F
Rotor I      : F β†’ J
Rotor II     : J β†’ T
Rotor III    : T β†’ Z
Plugboard OUT: Z β†’ Z

The trace is:

  • deterministic
  • collapsible
  • optional
  • useful for learning and debugging

⌨️ Input and Output

  • True QWERTY keyboard
  • Lampboard highlights the output letter
  • Running ciphertext display
  • Reset clears output, not configuration

This mirrors real Enigma operation:

Clear the message. Keep the key.


πŸ“¦ Export and Import

Export

  • Copy configuration to clipboard
  • Download configuration as .json
  • Export contains only deterministic state

Import

  • JSON structure is validated
  • Machine is rebuilt cleanly
  • Output and trace are cleared

🧱 Architecture

Separation of Concerns

  • Logic layer: Rotor, Plugboard, Enigma
  • UI layer: visualization and controls only

Logic is deterministic and UI-agnostic.


❗ What This Is (and Is Not)

This IS:

  • a faithful mechanical simulation
  • deterministic and inspectable
  • reproducible and debuggable

This IS NOT:

  • modern cryptography
  • secure encryption
  • random or probabilistic

🧭 Why Build This?

For the same reason as the Provably Fair Dice Roller:

Trust is strongest when it is unnecessary.

By exposing every transformation, the simulator replaces mystery with understanding.


Check this project here.

Built with Next.js, React, and deliberate transparency.

Β© 2025 Emil Irgi. All Rights Reserved. Template by Takuya Matsuyama.