arXiv:2508.10235cs.LG2025-08被引 1

用上下文学习让Transformer破解替换密码,测试其推理能力。

Can Transformers Break Encryption Schemes via In-Context Learning?

  • 用少量密文-明文对作为上下文,让Transformer推断加密映射规则。
  • 在单字母替换和维吉尼亚密码上实现高精度解码,证明可泛化到复杂加密结构。
  • 适合研究大模型推理机制与密码学安全性的交叉方向学者。

上下文学习(ICL)已成为基于Transformer的语言模型的一项强大能力,使其能在推理时仅通过少量示例进行条件判断,无需参数更新即可完成任务。已有研究表明,Transformer可从上下文中泛化到线性函数、决策树甚至神经网络等简单函数类,主要聚焦于数值或符号推理。本文首次将ICL应用于密码学函数学习领域,重点研究单字母替换密码和维吉尼亚密码这两种私钥加密方案。这些密码涉及明文与密文字符间的固定但隐藏的双射映射。给定一组(密文, 明文)对,目标是让模型推断出底层替换规则并解码新密文。该设定构成结构化推理挑战,非常适合评估Transformer在ICL范式下的归纳偏置与泛化能力。代码已开源:https://github.com/adistomar/CS182-project。

原文摘要 · Abstract (English)

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.

上下文学习密码破解Transformer推理能力

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。