SALSA: Attacking Lattice Cryptography with Transformers

Emily Wenger, Mingjie Chen, François Charton, Kristin E. Lauter

Introduction

As the prospect of a "quantum apocalypse" looms, the cryptographic community has pivoted toward Post-Quantum Cryptography (PQC) to secure digital infrastructure. Standard public-key systems, such as RSA and Elliptic Curve Cryptography (ECC), are vulnerable to Shor’s algorithm on sufficiently powerful quantum computers. In their place, lattice-based schemes—specifically those based on the Learning With Errors (LWE) problem—have emerged as the primary candidates for standardization.

While traditional cryptanalysis of LWE relies on complex algebraic lattice reduction algorithms (e.g., BKZ), recent research introduces a novel paradigm: SALSA (Secret-recovery Attacks on LWE via Sequence-to-sequence models with Attention). This approach investigates whether Transformer models, which have demonstrated remarkable proficiency in symbolic reasoning and pattern recognition, can be leveraged to break quantum-resistant mathematical structures.

The LWE Challenge

The security of LWE-based systems is predicated on the difficulty of solving a noisy system of linear equations. Given a public matrix $A$, a secret vector $s$, and a small error vector $e$, an attacker is provided with $b = As + e \pmod q$. The objective is to recover $s$ given $A$ and $b$.

While algebraic attacks typically scale exponentially with the lattice dimension $n$, machine learning (ML) offers a statistical alternative. SALSA explores whether Transformers can overcome the inherent challenges of modular arithmetic—where values "wrap around" a modulus $q$—and the presence of stochastic noise to extract secret keys.

The SALSA Methodology

The SALSA framework treats the cryptographic attack as a sequence-to-sequence task, utilizing a pipeline designed to bridge the gap between deep learning and modular linear algebra.

1. Modular Arithmetic Pre-training

The researchers first established that Transformers can learn modular multiplication and dot products, provided the numerical encoding is optimized. This foundational step ensures the model can approximate the underlying linear structure of the LWE problem.

2. The Attack Pipeline

The model $\mathcal{M}$ is trained to predict the output $b$ from an input vector $a$. A critical insight of SALSA is that the model does not require perfect accuracy to be effective. Even a partially trained model that captures subtle statistical biases can serve as a "distinguisher" to leak information about the secret.

3. Secret Recovery Algorithms

SALSA employs two primary methods for key recovery:

  • Direct Secret Recovery: The model is queried with "special" inputs, such as unit vectors. If the model has internalized the relationship defined by the secret $s$, its predictions for these specific inputs directly reveal the individual bits of the secret vector.
  • Distinguisher Secret Recovery: Based on a formal reduction proof, the model is used to differentiate between valid LWE samples and random noise. By perturbing the input data and observing the model's response, the secret can be recovered bit-by-bit.

4. Verification

Once a candidate secret $s'$ is generated, it is verified by calculating the residuals $b - As'$. If the resulting vector follows the expected narrow Gaussian error distribution, the secret is confirmed as correct.

Experimental Setup and Insights

The study focused on standard LWE and Ring-LWE (RLWE) instances with dimensions $n$ ranging from 30 to 128 and a modulus $q \approx 251$. The experiments targeted sparse binary secrets (vectors with low Hamming weight), a configuration common in efficient homomorphic encryption implementations like HEAAN.

Key Findings

  • The "Aha!" Moment: Training curves for SALSA exhibit a characteristic "step" function. The model often shows no progress for an extended period before suddenly "clicking," at which point accuracy increases rapidly as it masters the modular structure.
  • Encoding Sensitivity: The choice of base for integer representation (e.g., base-2 vs. base-81) significantly influences learning efficiency. Certain encodings act as a side-channel, making the secret more transparent to the Transformer's attention mechanism.
  • Attack Efficiency: For a dimension $n=50$, SALSA can recover the secret in under five hours using approximately $2^{22}$ samples. Furthermore, the attack is highly resilient to noise, succeeding even when the error standard deviation $\sigma$ is increased significantly beyond standard parameters.
  • Sample Augmentation: To improve data efficiency, the researchers demonstrated that an attacker can generate new training samples by taking linear combinations of a limited set of intercepted LWE samples.

Results and Scaling

SALSA represents a significant leap in ML-based cryptanalysis, successfully recovering secrets for dimensions up to $n=128$. This is a notable improvement over previous ML attacks, which frequently stalled at $n=20$. The "Direct" recovery method proved particularly robust, accounting for the majority of successful attacks.

Limitations and Conclusion

While SALSA demonstrates the potential of Transformers in cryptanalysis, several hurdles remain before it can threaten production-level systems like Kyber, which utilize higher dimensions ($n \ge 256$) and non-sparse secrets. Additionally, the computational cost of training large-scale Transformers remains a limiting factor.

Nevertheless, SALSA proves that Transformers are a credible new tool in the cryptanalyst's arsenal. By shifting the focus from purely algebraic methods to statistical pattern matching, this research suggests that the security margins of lattice-based cryptography must be re-evaluated in the context of advancing machine learning capabilities.

Summary updated

BibTeX
@inproceedings{wenger2022salsa,
  author = {Emily Wenger and Mingjie Chen and François Charton and Kristin E. Lauter},
  title = {{SALSA: Attacking Lattice Cryptography with Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=RzUB1S-XXsO},
}
Figure