Automating Bitvector and Finite Field Equivalence Proofs in Lean
This paper introduces BitModEq, a novel Lean tactic that automates equivalence proofs between bitvectors and finite fields using range lemmas and case analysis, outperforming state-of-the-art SMT solvers in verifying Zero-Knowledge Proof circuit encodings.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Big Picture: Two Different Languages for Math
Imagine you are trying to verify that a secret recipe (a Zero-Knowledge Proof) works correctly. The problem is that the recipe is written in two different languages that don't mix well:
- Finite Fields: Think of this as a "Clock Math" world. If you have a clock with 17 hours, adding 10 and 10 doesn't give you 20; it gives you 3 (because you wrap around). This is how many modern cryptographic systems (like those used in cryptocurrencies) do their math.
- Bitvectors: Think of this as "Computer Math." Computers don't wrap around like clocks; they just have a fixed number of switches (bits) that are either on or off. If you add numbers and run out of switches, the extra bits just get chopped off.
The Problem:
When developers build these cryptographic systems, they have to translate the "Clock Math" into "Computer Math" to make it run on real hardware. This translation is called arithmetization.
- If the translation is wrong, the whole security system is broken.
- Checking if the translation is correct is incredibly hard.
- Manual checking is like proofreading a novel by reading every word with a magnifying glass: it's accurate but takes forever and is prone to human error.
- Automatic checking (using standard computer solvers) is like using a spell-checker: it's fast, but it often gets confused by the weird "Clock Math" rules and gives up on complex sentences.
The Solution: The "BitModEq" Translator
The authors built a new tool called BitModEq inside a system called Lean (which is like a super-strict math tutor that checks every step of a proof).
Think of BitModEq as a specialized translator that doesn't just swap words; it understands the logic behind the words. It uses a three-step process to prove that the "Clock Math" recipe is exactly the same as the "Computer Math" recipe:
Step 1: The "Unwrapping" (Translation)
The tool takes the "Clock Math" (Finite Fields) and tries to "unwrap" it into normal numbers (Natural Numbers).
- The Challenge: In Clock Math, $5 - 10$ might be a positive number because of the wrap-around. In normal math, it's negative.
- The Trick: The tool looks at the numbers and asks, "Is it possible for this number to wrap around?" If the numbers are small enough (like bits in a computer), it knows wrapping won't happen. It safely removes the "Clock" rules and treats them as normal math. If it's not sure, it keeps the "Clock" rules but adds a safety check.
Step 2: The "Safety Net" (Range Analysis)
This is the paper's secret sauce. Before the tool tries to convert the math into computer bits, it performs a Range Analysis.
- The Analogy: Imagine you are packing a suitcase. You don't just throw clothes in; you check the size of the suitcase and the size of the clothes.
- How it works: The tool looks at the variables and asks, "What is the biggest this number could possibly be?"
- If it knows a number is between 0 and 1 (like a single light switch), it can ignore the complex "Clock" rules entirely.
- This step is crucial because it simplifies the problem so much that the computer can solve it easily. Without this "safety net" check, the computer gets overwhelmed by the complexity.
Step 3: The "Bit-Blasting" (Final Proof)
Once the tool has simplified the problem into pure "Computer Math" (bits), it uses a technique called bit-blasting.
- The Analogy: This is like taking a complex lock and trying every single combination of keys until you find the one that opens it.
- Because the tool simplified the problem in Step 2, the "lock" is now small enough for the computer to try every combination instantly and prove the math is correct.
Why This Matters (The Results)
The authors tested their tool on real-world cryptographic systems (specifically Jolt and CirC).
- The Competition: They compared their tool against the best existing automatic solvers (like
cvc5). - The Result: The existing solvers often got stuck or timed out when the problems got big (like 32-bit numbers). They were like a spell-checker trying to read a dictionary.
- BitModEq's Win: The new tool solved 19% more problems than the best existing tools. It could handle much larger numbers (up to 32 bits) where the others failed.
- Bonus: Because it runs inside Lean, the proof is kernel-checked. This means the computer didn't just guess; it followed a strict set of logical rules that are guaranteed to be correct, shrinking the risk of hidden bugs.
A Real-World Discovery
During their testing, the tool actually found a bug in the CirC compiler. The compiler had a mistake in how it handled large numbers (specifically, a 32-bit right shift). The bug only showed up with large numbers, which is why previous, smaller-scale tests missed it. The developers fixed the bug after the authors reported it.
Summary
The paper presents a new way to automatically verify that cryptographic math works correctly. Instead of struggling to translate between "Clock Math" and "Computer Math" manually or with clumsy tools, they built a smart translator that:
- Checks the size of the numbers first (Range Analysis).
- Simplifies the math by removing unnecessary "Clock" rules.
- Uses brute-force logic to prove the final result is correct.
This makes verifying complex security systems faster, more reliable, and capable of catching bugs that other tools miss.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.