Skip to content

Exploring the cryptographic limits of Transformer networksExploring the Cryptographic Limits of Transformer Networks

arXiv· arXiv:2606.29389· Stefan Domunco, Andis Draguns, Philip Torr, Isaac Robinson, Christian Schroeder de WittUniversity of Oxford; Contramont ResearchIndexed by this site · 25 days ago· Originally publishedAlignment

Quick read

Analysis and theory

Based on the paper PDF (AI-generated); refer to the original

The authors compiled Keccak, MDC, and Merkle Tree into threshold circuits and gave two mappings to transformers; the derived depth and width formulas agree with the compiled circuits in all tested configurations.

Questions
Colluding AI agents can exchange information using steganography, and this only requires the model to be able to compute cryptographic hash functions; no prior work has mapped concrete cryptographic constructions to transformer architectures, and their cryptographic expressivity lacks a structural characterization.
Methods
Using the Reifier compiler, three classes of hash constructions—Keccak, Merkle–Damgård, and Merkle Tree—are compiled into layered threshold circuits, depth and width scaling laws are derived and checked, and then two constructive mappings to transformer encoders are proposed: no-attention and tokens-as-gates.
Experiments and results
The derived depth and width formulas agree exactly with the compiled circuits across all tested configurations (Tables 2–4); the MD construction is deep and narrow, while MT is shallow and wide; the depth of both mappings is O(depthcircuit), and their FFN width characteristics differ.
Limitations and future work
The mappings were not empirically validated through training; tokens-as-gates assumes unnormalized hard attention; the experiments are all toy-scale instances, and the formula constants are artifacts of the Reifier compiler; the MT experiments are limited to inputs requiring no padding.
Experimental setupcircuit depth、circuit width et al.
Metrics
circuit depthcircuit widthFFN width
AI summaryThe paper converts three classes of cryptographic constructions—the Keccak function, the Merkle–Damgard construction and Merkle trees—into threshold circuits, then maps them to different Transformer architectures, deriving the width and depth scaling laws required to implement each construction. Based on the conclusion that saturated Transformers can be viewed as threshold circuits, the authors propose two mappings: the attention-free mapping and the tokens-as-gates mapping. The motivation is that prior work has shown that colluding AI agents can exchange malicious information using steganographic methods, and whether steganography can be achieved depends on which cryptographic functions a Transformer can implement. The authors state that the work also gives constructive upper bounds on what a Transformer of given depth and width can compute, providing a methodological basis for capability evaluation.

The paper converts three classes of cryptographic constructions—the Keccak function, the Merkle–Damgard construction and Merkle trees—into threshold circuits, then maps them to different Transformer architectures, deriving the width and depth scaling laws required to implement each construction. Based on the conclusion that saturated Transformers can be viewed as threshold circuits, the authors propose two mappings: the attention-free mapping and the tokens-as-gates mapping. The motivation is that prior work has shown that colluding AI agents can exchange malicious information using steganographic methods, and whether steganography can be achieved depends on which cryptographic functions a Transformer can implement. The authors state that the work also gives constructive upper bounds on what a Transformer of given depth and width can compute, providing a methodological basis for capability evaluation.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Whether transformers can implement cryptographic hash functions lacks a circuit-level characterization; the authors give threshold circuits and mappings for three classes of constructions.

    Core question: whether the transformer architecture can implement the three classes of cryptographic hash constructions—Keccak, Merkle–Damgård, and Merkle Tree—and at how deep and how wide a scale; no prior work has given a circuit-level answer.

    • Safety background: the authors state that colluding AI agents can use steganography to exchange sensitive information in seemingly harmless messages [1], and that backdoors can be compiled into transformers and cannot be detected in polynomial time by activation-based interpretability methods [6].
    • Why this is a cryptographic problem: Theorem 3 of [1] shows that the above steganographic collusion only requires the model to be able to compute cryptographic hash functions, so the cryptographic expressivity of transformers directly constitutes a safety problem.
    • Gap in existing work: Merrill et al. [2] proved that saturated transformers can be represented as TC0 threshold circuits, but the authors point out that no concrete work maps cryptographic constructions such as Keccak, MDC, and MT through circuit representations to transformer architectures.
    • Core approach: first use the Reifier compiler to compile the three classes of constructions into layered threshold circuits, derive and verify depth and width scaling laws, and then propose two concrete mappings from circuits to transformers.
    • Paper's output: the authors state that this is the first systematic circuit-level analysis of these constructions in the context of transformer expressivity, and that it provides a methodological basis for structural guarantees in capability-based AI safety evaluation (eval science).
  2. What related research exists?

    It draws on two lines of literature: the TC0 characterization of saturated transformers and steganographic collusion among agents; the cryptographic constructions themselves are taken from classical work.

    Circuit complexity characterization of transformers

    • Merrill et al. (2022) [2]—proved that saturated transformers can be represented as TC0-class constant-depth threshold circuits; this paper's circuit-to-transformer mapping builds directly on that result.
    • Hajnal et al. (1993) [10]—defined threshold gates and the TCi circuit classes, providing the basis for this paper's circuit formalization.
    • Vaswani et al. (2017) [8] and Shazeer (2020) [9]—the transformer architecture and SwiGLU gating; this paper uses only the encoder stack, and the FFN uses SwiGLU to match the MLP compiled by Reifier.

    AI agent collusion and backdoors

    • Motwani et al. (2024) [1]—showed that colluding AI agents can exchange malicious information via steganography; their Theorem 3 attributes this capability to the model being able to compute cryptographic hash functions, which is this paper's security motivation.
    • Draguns et al. (2024) [6]—showed that backdoors can be compiled into transformers and cannot be detected in polynomial time by activation-based interpretability methods; the authors state that such backdoors can be triggered by steganographic inputs from colluding agents or external attackers.
    • Cachin (2004) [5]—an information-theoretic model of steganography.

    Cryptographic constructions

    • Merkle (1989) [11] and Damgård (1989) [12]—independently proposed the Merkle–Damgård construction for building collision-resistant hashes from compression functions.
    • Merkle [13]—the Merkle Tree construction; Bertoni et al. (2011) [14]—the sponge construction, of which Keccak is one function family.

    Tools and evaluation

    • Reifier [15]—a library that compiles Boolean functions into layered threshold circuits (implemented as SwiGLU-gated MLPs); all compiled circuits in this paper were generated by it.
    • Liang et al. (2023) [7]—the HELM holistic evaluation; the authors position this paper as a structural capability guarantee for this kind of AI safety evaluation.

    Authors' positioning: prior work separately established the circuit-theoretic limits of saturated transformers and the security concerns of agent collusion; this paper fills the intermediate link—mapping concrete cryptographic constructions to transformer architectures. The paper has no baseline comparison experiments.

  3. How does the paper address this problem?

    Reifier is used to compile three classes of hash constructions into threshold circuits, scaling laws are derived, and then two mappings to transformer encoders are given.

    The overall approach has two steps: first compile cryptographic constructions into layered threshold circuits and derive depth and width scaling laws, then map the circuits to a transformer encoder stack, giving constructive upper bounds on depth and FFN width.

    Circuit compilation and object selection

    • Compilation tool: the Reifier library [15] traces each bit operation (AND, OR, NOT) of a Boolean function f : {0,1}ⁿ → {0,1}ᵐ as a threshold gate, generating a layered DAG; to satisfy the MLP layered structure it inserts identity nodes, and the authors note its limitation is that when values need to be carried across multiple layers it produces very wide MLPs.
    • Analysis objects: the Keccak function, the Merkle–Damgård construction (MDC), and Merkle Tree (MT); the authors state they were chosen because they represent three classes of hash methods and are widely deployed.
    • Experimental scale: all are toy versions, e.g. Keccak with w=1, nrounds=1, 17-bit input; MDC and MT use a toy Keccak with w=1, nrounds=1, r=12 as the compression function.

    Scaling law derivation

    • Keccak: one round contains six layers (θ: 2, χ: 3, ι: 1; ρ and π are only wiring and occupy no layers); for a single block the depth is depthcircuit = 6nrounds + 2, the widest layer is the first θ layer with width 11 · 25w; after extending to arbitrary-length input and arbitrary-length output, the width takes the larger of the absorption and squeezing bottlenecks (Equation 11), and the depth increases with the number of blocks and additional f calls (Equation 12).
    • MDC: the depth per block is 2 + 1 + 6nrounds (XOR into the chain, build the Keccak state, Keccak itself), and the overall depthMDc = 1 + depthc · Nb + 1; the width is largest at the first compression, widthMDc = widthc + (Nb − 1) · Nsize.
    • MT: a binary tree, depthcircuit = log2(nleaves) · (3 + 6nrounds) + 2 + 6nrounds, width widthcircuit = nleaves · 11 · 25w, widest where leaves are computed in parallel.
    • Verification method: the formulas were checked against the actual compiled circuits configuration by configuration; the authors note that the multiplicative constants in the formulas are artifacts of the Reifier compiler, so they also give asymptotic forms (Equations 13, 14, 17, 18, 21, 22).

    Mapping one: no-attention

    • Design: attention is ignored entirely, the whole input is stored in a single token, and each dimension of the token stores one wire value; requires d ≥ widthcircuit, T = 1.
    • Depth: each FFN simulates one circuit layer, and the transformer depth is O(depthcircuit); each FFN corresponds directly to a SwiGLU layer generated by Reifier.
    • Lower bound: the authors argue that any mapping has depthT ≥ depthcircuit, because a single sublayer (attention or FFN) can evaluate at most one circuit layer at a time.

    Mapping two: tokens-as-gates

    • Design: each token represents one gate, T = total number of gates G; the first T dimensions of the token embedding are the one-hot encoding of the gate, dimension T+1 stores the gate's current value, and dimension T+2 stores the threshold θ.
    • Attention: simulates circuit wiring using unnormalized hard attention (predecessors score 1, all others 0); the authors explicitly state this is an idealized assumption about standard softmax; the attention output is the sum of predecessor gate values, and the FFN then compares with the threshold to complete the gate computation.
    • Depth: each encoder sublayer simulates one circuit layer, depthencoder = O(depthcircuit), consistent with the lower bound; the correctness analysis is in Appendix E.
  4. What experiments did the paper conduct?

    Circuits were compiled on toy-scale instances and the formulas checked configuration by configuration; predicted and actual depth and width agree in all tests.

    Experimental setup

    • Experimental objects: toy instances of three constructions—the Keccak function, MDC, and MT—compiled into layered threshold circuits with Reifier; no real language model is involved.
    • Keccak configurations: log w ∈ {1, 2}, r ∈ {25, 50}, number of blocks ∈ {1, 2, 4}, number of rounds ∈ {1, 2}; additionally a squeezing experiment with log w=2, nrounds=1, 64-bit output, r=25.
    • MDC configurations: the compression function is a toy Keccak with w=1, nrounds=1, r=12; log w ∈ {1, 2}, block size ∈ {4, 8} bits, number of blocks ∈ {1, 2, 3, 4}, number of rounds ∈ {1, 2}, 0* padding.
    • MT configurations: binary tree, log w ∈ {1, 2}, number of rounds ∈ {1, 2}, number of leaves ∈ {1, 2, 4, 8}; limited to inputs requiring no padding.
    • Metrics and criterion: predicted circuit depth and width (formulas) versus actual values (compilation results), compared configuration by configuration for equality; no statistical tests, no number of repetitions reported.

    Main results

    Formula verification (according to Tables 2, 3, 4, the Exp. and Actual values are exactly equal in every row; the table below takes some configurations):

    Swipe horizontally to read the table

    ConstructionConfigurationPredicted/actual depthPredicted/actual width
    Keccak (Table 2)log w=1, r=25, 1 block, 1 round10 / 10550 / 550
    Keccak (Table 2)log w=1, r=25, 4 blocks, 2 rounds58 / 58625 / 625
    Keccak (Table 2)log w=2, r=50, 4 blocks, 2 rounds58 / 581250 / 1250
    MDC (Table 3)log w=1, 4-bit block, 4 blocks, 2 rounds62 / 62562 / 562
    MDC (Table 3)log w=2, 8-bit block, 4 blocks, 2 rounds62 / 621124 / 1124
    MT (Table 4)log w=1, 8 leaves, 2 rounds59 / 594400 / 4400
    MT (Table 4)log w=2, 8 leaves, 2 rounds59 / 598800 / 8800
    • The authors state that for all three constructions the predicted and actual depth and width are exactly consistent in all tested configurations (Tables 2–4 and Figures 2, 3, 5, 6, 8, 9).
    • The authors state that the experiments confirm all three constructions admit threshold circuit representations, and their scaling laws directly constrain the transformer architectures needed to implement them.

    Deviations in depth predictions

    • Phenomenon: Table 1 lists deviations from the linear prediction depthpred = 6nrounds + 2: with log w=2, nrounds=13 the observed value is 79 (∆=−1); with nrounds=19 the observed value is 114 (∆=−2); with log w=3, nrounds=15 the observed value is 91 (∆=−1).
    • Authors' explanation: when the round constant RC[ir] = 0 the ι layer is omitted; this is an artifact of the Reifier compiler rather than a property of the construction itself; with log w=4, nrounds=24 the observed value 146 agrees with the prediction.

    Comparison between constructions and between mappings (Discussion)

    • MD versus MT: the authors state that MD produces deeper and narrower circuits and MT shallower and wider ones, a depth–width trade-off; the two have total computation of the same order, both requiring O(Nb · nc) gates.
    • The two mappings: in no-attention the FFN width grows linearly with circuit width; in tokens-as-gates the FFN width is constant, but more tokens are needed and attention routing is introduced.
    • Information readable from figure captions: Figure 2 notes that the depth difference comes from round constants equal to 0; the legends of Figures 5, 6, 8, 9 give the prediction formulas (e.g. 1 + depthc · Nb + 1, nleaves · widthc) alongside the Actual curves.

    Other ablations and analyses

    • Keccak arbitrary output length experiment: log w=2, nrounds=1, 1 block, 64-bit output, r=25; the squeezing stage introduces a second width bottleneck (Equation 11).
    • Layer-by-layer inspection of the MT circuit (Appendix D): with 8-bit input and 2 leaves there are 17 layers in total (excluding the input layer), 7 fleaves layers, 9 fnodes layers, and 1 output layer; the second layer is 2 · 50 = 100 nodes wide.
    • MD Appendix C note: when executing Keccak the width increases by 4, because the input bits awaiting absorption must be retained.
  5. What are some points that can be further explored?

    The authors list limitations such as no empirical validation through training, the hard-attention assumption, and toy scale, and propose directions such as constructing explicit transformers.

    Limitations and future directions noted by the authors

    • Not validated by training: the mappings are constructive and have not been empirically validated through training; whether gradient descent can learn to implement these constructions is an open question (Conclusion and Further Work).
    • Idealized attention assumption: the tokens-as-gates mapping assumes unnormalized hard attention, and there is a gap between the theoretical model and transformers as actually used (Conclusion and Further Work).
    • Toy scale and compiler constants: the experiments are conducted on constructed toy instances, and the formula constants are products of the Reifier compiler; different compilers may give tighter bounds (Conclusion and Further Work).
    • Full constructions unconfirmed: whether the scaling laws apply unconditionally to the full Keccak permutation used in SHA-3, or to production-scale MD constructions, remains to be confirmed (Conclusion and Further Work).
    • MT padding limitation: circuit generation is inconsistent when padding is required, so the MT experiments are limited to inputs that need no padding; generalization to padded inputs is left for future work (Section 4.3).
    • Future directions: construct explicit transformers with specified attention heads and embedding dimensions, test whether gradient descent can learn these functions, and develop alternative mappings such as tokens-as-states or tokens-as-values; the authors also hope to develop circuit-theory-based benchmark evaluations of frontier models (Conclusion and Further Work).

    Scope of experimental coverage

    • The experiments cover toy instances of the three classes of constructions: Keccak with log w ≤ 2 and rounds ≤ 2 (Table 2), MDC with blocks ≤ 4 (Table 3), and MT with leaves ≤ 8 (Table 4).
    • Validation consists of comparing formulas with compiled circuits configuration by configuration; the paper reports no number of repetitions or statistical tests.
    • The experiments involve no real language models: no transformer weights are trained or tested, and the mappings have only constructive arguments (Appendix E gives an algebraic analysis of tokens-as-gates).
    • The Keccak depth formula deviates in some configurations (∆ is −1 or −2 in Table 1), which the authors attribute to the compiler omitting the ι layer when the round constant is 0.
  6. Summarize the main content of the paper

    The authors give threshold-circuit scaling laws for three classes of hash constructions and two transformer mappings; the formulas agree with the compiled circuits in all cases.

    A theoretical work on a structural characterization of transformer computational capability, motivated by AI safety: the authors state that steganographic communication among colluding agents only requires the model to be able to compute cryptographic hash functions, so the cryptographic expressivity of transformers is directly a safety problem.

    • Problem: prior work proved that saturated transformers belong to TC0, but did not map concrete cryptographic constructions to transformer architectures; this paper fills that gap.
    • Method: the Reifier compiler is used to compile Keccak, MDC, and MT into layered threshold circuits, and depth and width scaling laws are derived; two mappings to the encoder stack are proposed, no-attention and tokens-as-gates, both with depth O(depthcircuit).
    • Results: the formulas agree with the compiled circuits across all tested configurations, e.g., Keccak with log w=1, r=25, 1 block, 1 round has depth 10 and width 550 (Table 2); MT with log w=2 and 8 leaves has width 8800 (Table 4).
    • Exception: Keccak depth is 1–2 layers less in a few configurations (Table 1), which the authors attribute to the compiler omitting the ι layer when the round constant is 0.
    • Authors' conclusion: MD is deep and narrow, MT is shallow and wide, and there is a depth–width trade-off; the two mappings each have trade-offs in FFN width and token requirements.
    • Boundaries stated by the authors: the mappings are not validated by training, hard attention is an idealized assumption, and the experiments are at toy scale; the authors hope to use this to develop circuit-theory-based capability evaluations of frontier models.
Read originalarxiv.org