Learning Plaintext-Ciphertext Cryptographic Problems via ANF-based SAT Instance Representation

Xinhao Zheng, Yang Li, Cunxin Fan, Huaijin Wu, Xinhao Song, Junchi YanNeurIPS 2024

TL;DR

Standard neural SAT solvers struggle with cryptography because converting XOR operations into Conjunctive Normal Form (CNF) causes a massive "scale explosion" in the problem size. This paper introduces CryptoANFNet, a graph-based learning framework that uses Algebraic Normal Form (ANF) to represent cryptographic problems succinctly. By preserving high-level semantics, it achieves a 50x speedup over heuristic solvers and significantly outperforms state-of-the-art neural solvers in predicting satisfiability and recovering encryption keys.

What Problem Does This Paper Address?

Cryptanalysis—the art of breaking codes—often involves finding a secret key that links a known plaintext to its corresponding ciphertext. This is essentially a search problem in a binary space, which can be mathematically framed as a Boolean Satisfiability (SAT) problem.

However, there is a major bottleneck: most SAT solvers (and virtually all existing neural SAT solvers) rely on Conjunctive Normal Form (CNF). While CNF is versatile, it is terrible at representing the XOR operations that are the bread and butter of modern cryptography. Converting an XOR operation with $k$ variables into CNF requires nearly $2^{k-1}$ clauses. This exponential growth destroys the high-level structural patterns that a machine learning model might otherwise learn. The authors aim to bridge this gap by finding a more efficient way to represent and solve these "XOR-heavy" cryptographic SAT instances.

Methods

The authors pivot from CNF to Algebraic Normal Form (ANF). In ANF, formulas are expressed as polynomials using XOR (addition) and AND (multiplication) operations. This is naturally "XOR-friendly" and keeps the representation compact.

1. ANF-based Graph Representation: The authors represent the SAT instance as a tripartite graph consisting of:

  • Vanilla Literals: The basic variables.
  • Second-order Literals: Products of variables (representing AND operations).
  • Clauses: The equations themselves. This structure allows the model to capture higher-order operational information without the node-count explosion seen in CNF graphs.

2. CryptoANFNet: They propose a Graph Neural Network (GNN) that uses a message-passing scheme. Literals and clauses exchange information iteratively to refine their embeddings. Finally, a classifier predicts whether the given plaintext-ciphertext pair is "satisfiable" (i.e., if a valid key exists for that specific configuration).

3. Key-solving Algorithm: To actually recover a key, the authors use a "guess-and-check" strategy. For a specific bit in the key, they create two SAT instances: one where the bit is set to 0 and one where it is 1. Both are passed through CryptoANFNet, and the bit value is determined by which instance receives a higher satisfiability score.

The CryptoANFNet pipeline for key recovery using a guess-and-check strategy on ANF formulas.

Datasets

The model was evaluated on several synthetic and real-world-inspired datasets:

  • SR(n): Stochastic SAT instances in ANF, scaled to different variable counts ($n$).
  • Scipher: A dataset generated from a lightweight block cipher (the specific name is withheld for proprietary/security reasons, referred to as "Scipher").
  • SPECK: A well-known lightweight block cipher designed by the NSA, frequently used as a benchmark in neural cryptanalysis.
  • CNF Conversions: For comparison, these datasets were also converted to CNF to test against traditional solvers like NeuroSAT.

Key Insights and Ideas

  • Semantic Preservation: The "aha moment" is that by using ANF, the graph size for a problem like SR(25) drops from 6,340 nodes in CNF to just 77 nodes in ANF. This allows the GNN to "see" the entire problem structure much more clearly.
Comparison of graph sizes between CNF and ANF representations across different datasets.
  • Relative Scoring over Absolute Probability: For key recovery, the model doesn't need to be 100% certain. By comparing the scores of two related instances (bit=0 vs bit=1), the model can effectively "vote" for the correct key bit even if the individual satisfiability predictions are difficult.
  • Efficiency via AND-encoding: By explicitly representing second-order literals (AND products) as nodes, the model captures non-linear cryptographic transformations directly in the graph topology.

Key Results

  • Speed: CryptoANFNet achieves a 50x speedup on average compared to traditional heuristic solvers like WDSat and CryptoMiniSat.
  • Accuracy: On large-scale datasets from real encryption algorithms, CryptoANFNet achieved 72% accuracy, while the previous state-of-the-art (NeuroSAT) struggled at 55% (barely better than a coin flip).
  • Key Recovery: The specialized key-solving algorithm boosted decryption accuracy from 76.5% to 82% on the Scipher dataset and from 72% to 75% on SPECK.

Limitations and Future Work

  • Focus on MQ Problems: The paper focuses primarily on Multivariate Quadratic (MQ) problems derived from plaintext-ciphertext pairs. It does not fully explore other cryptographic primitives like hash functions or public-key systems.
  • Heuristic Dependency: While the model is fast, the authors acknowledge that cryptographic problems are inherently "hard" (NP-complete), and neural solvers are still an augmentation to, rather than a total replacement for, exhaustive search in high-security settings.
  • Future Directions: The authors suggest exploring more advanced neural architectures (like Transformers) and further optimizing the ANF graph structures to handle even deeper encryption rounds.

Summary updated

BibTeX
@inproceedings{zheng2024learning,
  author = {Xinhao Zheng and Yang Li and Cunxin Fan and Huaijin Wu and Xinhao Song and Junchi Yan},
  title = {{Learning Plaintext-Ciphertext Cryptographic Problems via ANF-based SAT Instance Representation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=FzwAQJK4CG},
}
Figure