hax
Hax translates Rust code into formal languages such as Lean, F*, and ProVerif, so you can prove that your code is panic-free, functionally correct, and meets its security goals.
How it works
-
Write Rust, state what it should do
Contracts are ordinary Rust attributes from
hax_lib.#[hax_lib::requires(x < 16)] #[hax_lib::ensures(|res| res >= x)] pub fn square(x: u8) -> u8 { x * x } -
Extract to a proof assistant
One command translates the crate into Lean, F*, or ProVerif.
cargo hax into lean -
Prove it
The contract becomes a theorem about the extracted code.
@[spec] theorem square.spec.proof (x : Std.U8) : square.spec x := by unfold square.spec square hax_mvcgen all_goals grind [Nat.le_mul_self]
More reading
- hax: Verifying Security-Critical Rust Software Using Multiple ProversKarthikeyan Bhargavan, Maxime Buyse, Lucas Franceschino, Lasse Letager Hansen, Franziskus Kiefer, Jonas Schneider-Bensch, Bas Spitters. VSTTE 2024.
- Formal Security and Functional Verification of Cryptographic Protocol Implementations in RustKarthikeyan Bhargavan, Lasse Letager Hansen, Franziskus Kiefer, Jonas Schneider-Bensch, Bas Spitters. ACM CCS 2025.
- The hax blogTechnical posts on hax and its applications.
News
-
Developer-driven Rust verification using hax, Lean, and AI
Showcasing hax 0.4 on IoT-friendly SHA-3
-
Hax 0.4!
Announcing hax 0.4, a pivotal release
-
Software Verification in Lean
Pereq co-hosted a workshop on advancing software verification using the Lean proof assistant.
-
Formally Specifying and Testing the Rust Standard Library
Pereq found and fixed bugs in the Rust SIMD libraries using formal specs
-
Helping Secure Signal's Post-Quantum Transition
Pereq worked with Signal to formally analyze their new post-quantum ratchet
Community
Questions and discussion on Zulip, issues and contributions on GitHub.