[Paper Review] The Last Mile: High-Assurance and High-Speed Cryptographic Implementations
This paper presents a novel framework that combines Jasmin and EasyCrypt to generate high-assurance, high-speed cryptographic implementations in assembly, achieving functional correctness and side-channel resistance through 'game-hopping' verification. The authors produce formally verified, vectorized ChaCha20-Poly1305 implementations that outperform the fastest non-verified counterparts, demonstrating that formal verification need not sacrifice performance.
We develop a new approach for building cryptographic implementations. Our approach goes the last mile and delivers assembly code that is provably functionally correct, protected against side-channels, and as efficient as hand-written assembly. We illustrate ur approach using ChaCha20-Poly1305, one of the mandatory ciphersuites in TLS 1.3, and deliver formally verified vectorized implementations which outperform the fastest non-verified code. We realize our approach by combining the Jasmin framework, which offers in a single language features of high-level and low-level programming, and the EasyCrypt proof assistant, which offers a versatile verification infrastructure that supports proofs of functional correctness and equivalence checking. Neither of these tools had been used for functional correctness before. Taken together, these infrastructures empower programmers to develop efficient and verified implementations by "game hopping", starting from reference implementations that are proved functionally correct against a specification, and gradually introducing program optimizations that are proved correct by equivalence checking. We also make several contributions of independent interest, including a new and extensible verified compiler for Jasmin, with a richer memory model and support for vectorized instructions, and a new embedding of Jasmin in EasyCrypt.
Motivation & Objective
- Address the gap between high-assurance cryptographic implementations and high-performance hand-optimized code by enabling formal verification at the assembly level.
- Overcome the limitations of prior approaches that compromise on efficiency, trust, or developer adoptability by integrating optimization and verification in a single workflow.
- Enable cryptographic engineers to develop optimized, formally verified implementations using a practical, incremental methodology grounded in functional correctness and equivalence proofs.
- Provide a verified, extensible compiler for Jasmin with support for vectorized instructions and a richer memory model, ensuring predictable and correct compilation to assembly.
- Establish a new embedding of Jasmin in EasyCrypt to support automated proofs of functional equivalence and constant-time security.
Proposed method
- Use the Jasmin language to write readable reference implementations that combine high-level and low-level programming features, enabling 'assembly in the head' development.
- Apply the 'game-hopping' technique to gradually optimize the reference implementation into a vectorized, platform-specific version while proving each transformation preserves functional correctness.
- Leverage EasyCrypt's relational program logic to formally verify functional equivalence between reference and optimized implementations.
- Introduce a new embedding of Jasmin into EasyCrypt that supports proofs of functional correctness and constant-time security, including independence of control flow and memory access from secret data.
- Verify the Jasmin compiler in Coq to ensure that the transformation from Jasmin to assembly is correct and preserves all guarantees.
- Use static analysis and a simplified semantics during verification to ensure safety, with final proofs of constant-time behavior under the cryptographic constant-time model.
Experimental results
Research questions
- RQ1Can a formal verification framework be designed to support both high-assurance and high-performance cryptographic implementations without sacrificing efficiency?
- RQ2Can the 'game-hopping' technique be effectively adapted from cryptographic proofs to the verification of low-level code optimizations in cryptographic implementations?
- RQ3Is it possible to achieve performance comparable or superior to hand-optimized, non-verified assembly while maintaining formal guarantees of functional correctness and side-channel resistance?
- RQ4How can a verified compiler for a high-assurance language like Jasmin be extended to support vectorized instructions and complex memory models?
- RQ5Can a unified proof infrastructure be built in EasyCrypt to support both functional correctness and constant-time security proofs for low-level cryptographic code?
Key findings
- The authors deliver formally verified, vectorized implementations of ChaCha20 and Poly1305 in Jasmin that outperform the fastest non-verified assembly implementations, including those in OpenSSL and HACL*.
- The verified AVX2-optimized implementation of ChaCha20 achieves a performance of under 1.5 cycles per byte for large messages, surpassing HACL* compiled with CompCert and non-verified OpenSSL code.
- The verified Poly1305 implementation using AVX2 instructions achieves a performance of under 1.2 cycles per byte for large messages, significantly outperforming non-verified and verified alternatives.
- The framework enables verification of functional correctness and constant-time behavior for optimized code, with equivalence proofs between reference and optimized versions factored via generic lemmas.
- The new Jasmin compiler extension supports vectorized instructions and a richer memory model, and is formally verified in Coq, ensuring correctness from source to assembly.
- The embedding of Jasmin in EasyCrypt supports automated proofs of functional equivalence and constant-time security, enabling scalable verification of performance-critical code.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.