[Paper Review] Learning the Enigma with Recurrent Neural Networks
This paper proposes a sequence-to-sequence RNN model using Long Short-Term Memory (LSTM) networks to learn the decryption functions of polyalphabetic ciphers—specifically Vigenère, Autokey, and the 3-wheel Enigma—by training on plaintext-ciphertext pairs. The key contribution is demonstrating that RNNs can autonomously learn efficient internal representations of complex, deterministic ciphers and perform cryptanalysis via known-plaintext attacks, even generalizing to unseen keys and longer messages.
Recurrent neural networks (RNNs) represent the state of the art in translation, image captioning, and speech recognition. They are also capable of learning algorithmic tasks such as long addition, copying, and sorting from a set of training examples. We demonstrate that RNNs can learn decryption algorithms -- the mappings from plaintext to ciphertext -- for three polyalphabetic ciphers (Vigenère, Autokey, and Enigma). Most notably, we demonstrate that an RNN with a 3000-unit Long Short-Term Memory (LSTM) cell can learn the decryption function of the Enigma machine. We argue that our model learns efficient internal representations of these ciphers 1) by exploring activations of individual memory neurons and 2) by comparing memory usage across the three ciphers. To be clear, our work is not aimed at 'cracking' the Enigma cipher. However, we do show that our model can perform elementary cryptanalysis by running known-plaintext attacks on the Vigenère and Autokey ciphers. Our results indicate that RNNs can learn algorithmic representations of black box polyalphabetic ciphers and that these representations are useful for cryptanalysis.
Motivation & Objective
- To develop a general-purpose, automated method for reverse-engineering the decryption logic of black-box polyalphabetic ciphers.
- To investigate whether RNNs can learn algorithmic representations of complex ciphers without prior knowledge of their structure.
- To evaluate the model’s ability to generalize across unseen keys and message lengths.
- To explore whether memory usage in the RNN correlates with the time-dependence of the cipher’s encryption process.
- To demonstrate the utility of learned representations for cryptanalysis, such as keyphrase reconstruction.
Proposed method
- The model frames decryption as a sequence-to-sequence translation task using a 3000-unit LSTM network.
- Training data consists of paired plaintext and ciphertext sequences with corresponding keyphrases for each cipher.
- The model processes each character as a one-hot vector and uses attention-like mechanisms implicitly through the LSTM’s hidden state.
- Model performance is evaluated on generalization to unseen keys and longer message sequences beyond the training length.
- Internal representations are analyzed by visualizing activations of individual memory units across different ciphers.
- Keyphrase reconstruction is performed by modifying the input to include both plaintext and ciphertext vectors, training the model to predict the keyphrase.
Experimental results
Research questions
- RQ1Can an RNN learn the deterministic decryption function of a complex polyalphabetic cipher like the Enigma from only input-output examples?
- RQ2Does the memory capacity required by the RNN correlate with the time-dependence of the cipher’s encryption process?
- RQ3Can the RNN generalize to unseen keys and longer message sequences than seen during training?
- RQ4Do the internal activations of the LSTM’s memory units reflect meaningful structural properties of the underlying cipher?
- RQ5Can the learned internal representations be leveraged for cryptanalytic tasks such as keyphrase reconstruction?
Key findings
- The LSTM model achieved over 99% accuracy in decrypting Vigenère and Autokey ciphers, with the Autokey task requiring more memory due to dynamic key updates.
- The model generalized effectively to unseen keys and message lengths exceeding the training set, indicating robust internal representation learning.
- Memory usage scaled with cipher complexity: the Enigma required significantly more memory than Vigenère, reflecting its higher time-dependence.
- Activations of individual LSTM memory units mirrored qualitative features of the ciphers, suggesting structured internal representations.
- The model successfully reconstructed Vigenère keyphrases (1–6 characters) with over 99% accuracy and Autokey keyphrases with over 95% accuracy.
- The study demonstrates that RNNs can perform elementary cryptanalysis via known-plaintext attacks, revealing that learned representations are useful for reverse-engineering ciphers.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.