Can Transformers Break Encryption Schemes via In-Context Learning?

📅 2025-08-13
📈 Citations: 0
Influential: 0
📄 PDF

career value

187K/year
🤖 AI Summary
This work investigates whether large language models (LLMs) can implicitly infer mapping rules of classical ciphers via in-context learning (ICL). Specifically, it examines two private-key schemes—monoalphabetic substitution and the Vigenère cipher—and assesses whether Transformer-based models can decode unseen ciphertexts given only a few (ciphertext, plaintext) examples in the prompt, without parameter updates. It represents the first systematic application of ICL to cryptographic function learning. The study reveals LLMs’ inductive bias toward bijective mappings and their capacity for structural generalization. Experimental results demonstrate that models successfully recover plaintexts, exhibiting nontrivial reasoning over latent, structured patterns. These findings provide novel insights into the symbolic reasoning and cryptanalytic potential of foundation models, highlighting their ability to implicitly learn and apply deterministic, invertible transformations from minimal demonstrations.

Technology Category

Application Category

📝 Abstract
In-context learning (ICL) has emerged as a powerful capability of transformer-based language models, enabling them to perform tasks by conditioning on a small number of examples presented at inference time, without any parameter updates. Prior work has shown that transformers can generalize over simple function classes like linear functions, decision trees, even neural networks, purely from context, focusing on numerical or symbolic reasoning over underlying well-structured functions. Instead, we propose a novel application of ICL into the domain of cryptographic function learning, specifically focusing on ciphers such as mono-alphabetic substitution and Vigenère ciphers, two classes of private-key encryption schemes. These ciphers involve a fixed but hidden bijective mapping between plain text and cipher text characters. Given a small set of (cipher text, plain text) pairs, the goal is for the model to infer the underlying substitution and decode a new cipher text word. This setting poses a structured inference challenge, which is well-suited for evaluating the inductive biases and generalization capabilities of transformers under the ICL paradigm. Code is available at https://github.com/adistomar/CS182-project.
Problem

Research questions and friction points this paper is trying to address.

Investigates if transformers can learn encryption schemes via in-context learning
Focuses on deciphering mono-alphabetic substitution and Vigenère ciphers
Evaluates transformers' ability to infer hidden mappings from few examples
Innovation

Methods, ideas, or system contributions that make the work stand out.

Transformers learn ciphers via in-context examples
Focus on mono-alphabetic and Vigenère ciphers
Infer hidden mappings from cipher-plain text pairs
🔎 Similar Papers
No similar papers found.