Abstract
Verifying cryptographic software requires reasoning about constraints that span multiple modular domains, such as hardware-level $2^{64}$ arithmetic and field-level prime order arithmetic. This paper introduces a novel SMT refutation procedure implemented in cvc5 that leverages the integer domain as a central hub for information sharing. By employing "lifting" and "lowering" techniques alongside weighted Gröbner bases and Integer Linear Programming (ILP), the proposed method significantly improves the state-of-the-art in cryptographic verification, solving benchmarks that were previously out of reach for standard solvers.
Introduction
In modern cryptographic implementations, mathematical operations often occur in multiple "universes" simultaneously. For example, a protocol might be defined over a large prime field (e.g., a 255-bit prime for Ed25519), while the underlying implementation must execute on standard 64-bit CPU registers. Bridging these domains involves complex reduction techniques like Montgomery or Barrett reduction. For formal verification tools, these "multimodular" systems present a significant challenge: they must simultaneously reason about constraints modulo $n$ and modulo $m$, where $n$ and $m$ are often very large and coprime.
The Multimodular Challenge
Existing Satisfiability Modulo Theories (SMT) solvers typically approach these problems in one of two ways, both of which have significant drawbacks:
- Bit-blasting: Converting constraints into bit-vector logic. This fails to scale when dealing with 256-bit or 512-bit primes common in cryptography.
- Nonlinear Integer Arithmetic: Treating the constraints as general integer equations. This is computationally expensive and often fails to exploit the specific structure of modular arithmetic.
Crucially, standard solvers lack a dedicated mechanism to share information efficiently between different modular domains. A fact learned about a variable in the context of a prime field is rarely propagated to the context of bit-vector arithmetic.
A Centralized Integer Hub
The authors propose a specialized refutation procedure that treats the integer domain ($\mathbb{Z}$) as a central hub. The core strategy relies on three main operations:
1. Partitioning
The system first partitions constraints into subsystems based on their specific modulus $n$. This allows the solver to apply domain-specific reasoning to individual parts of the problem before attempting to bridge them.
2. Lifting and Lowering
- Lifting: This is the process of promoting a modular constraint (e.g., $e \equiv 0 \pmod n$) to an integer constraint ($e = 0$). This is sound if range analysis can prove that the expression $e$ cannot "wrap around" the modulus $n$.
- Lowering: Once a constraint is established in the integer domain, it becomes a "universal truth" that can be projected down into any other modular domain ($e \equiv 0 \pmod m$). This allows information to flow from one modulus to another via the integers.
3. Algebraic Lemma Generation
To facilitate lifting, the authors introduce two strategies to find "near-zero" polynomials that are likely to stay within a liftable range:
- Weighted Gröbner Bases: Standard Gröbner bases are "range-blind." By weighting the monomial ordering based on variable bounds, the solver biases its search toward polynomials with small coefficients and low degrees, which are more likely to be liftable to the integer domain.
- Integer Linear Programming (ILP): The solver uses an auxiliary ILP problem to find linear combinations of existing expressions that are guaranteed to remain within a range where lifting is valid.
Experimental Evaluation
The procedure was implemented in the cvc5 SMT solver and evaluated against 336 benchmarks derived from real-world cryptographic code, including Montgomery arithmetic and Zero-Knowledge Proof implementations (e.g., Succinct Labs and o1-labs). These benchmarks involve reasoning about 256-bit and 512-bit integers, representing a significant increase in complexity over standard SMT-LIB sets.
Key Results
- Performance:
cvc5solved 255 out of 336 benchmarks, significantly outperformingz3(190 solves),bitwuzla, andyices. - Unique Solves: The tool solved 76 benchmarks that no other tested solver could solve, demonstrating the necessity of the multimodular approach.
- Heuristic Synergy: The results showed that Weighted Gröbner Bases and ILP-based lifting are highly complementary; while neither is complete on its own, their combination yields the highest number of unique solves.
Conclusion and Future Work
By treating the integer domain as a bridge between disparate modular constraints, the authors have provided a powerful new tool for cryptographic verification. While the current procedure is a refutation-only heuristic (it cannot currently provide satisfying assignments for consistent constraints), it represents a major step forward in handling the complexity of modern cryptographic software. Future work includes scaling ILP techniques for even larger constants and developing custom ILP solvers tailored for these specific SMT encodings.
Summary updated