[Paper Review] Verified Low-Level Programming Embedded in F*
This paper presents Low∗, a verified, low-level programming language embedded in F∗ that enables efficient, memory-safe systems programming with formal verification. By combining F∗'s dependent types and verification capabilities with a CompCert-style memory model, Low∗ compiles to efficient, side-channel-resistant C code, achieving performance competitive with unverified C libraries while ensuring correctness and security through machine-checked proofs.
We present Low*, a language for low-level programming and verification, and its application to high-assurance optimized cryptographic libraries. Low* is a shallow embedding of a small, sequential, well-behaved subset of C in F*, a dependently-typed variant of ML aimed at program verification. Departing from ML, Low* does not involve any garbage collection or implicit heap allocation; instead, it has a structured memory model à la CompCert, and it provides the control required for writing efficient low-level security-critical code. By virtue of typing, any Low* program is memory safe. In addition, the programmer can make full use of the verification power of F* to write high-level specifications and verify the functional correctness of Low* code using a combination of SMT automation and sophisticated manual proofs. At extraction time, specifications and proofs are erased, and the remaining code enjoys a predictable translation to C. We prove that this translation preserves semantics and side-channel resistance. We provide a new compiler back-end from Low* to C and, to evaluate our approach, we implement and verify various cryptographic algorithms, constructions, and tools for a total of about 28,000 lines of code, specification and proof. We show that our Low* code delivers performance competitive with existing (unverified) C cryptographic libraries, suggesting our approach may be applicable to larger-scale low-level software.
Motivation & Objective
- To bridge the gap between high-level, formally verified code and low-level, high-performance systems code.
- To address security vulnerabilities in cryptographic software caused by memory safety violations such as buffer overflows.
- To enable efficient, verified implementations of cryptographic algorithms with performance comparable to unverified C code.
- To provide a verified compilation pipeline from high-level specifications to efficient, secure C code.
Proposed method
- Embedding a low-level, C-like subset of C into F∗ using a shallow embedding with a structured memory model inspired by CompCert.
- Using F∗'s dependent types and refinement types to express precise specifications and prove functional correctness and memory safety.
- Implementing a custom compiler back-end, KreMLin, to translate Low∗ code to efficient, predictable C code.
- Erasing proofs and specifications at extraction time to produce optimized, production-ready C code.
- Ensuring side-channel resistance through formal verification of the compilation process and memory model.
- Integrating Low∗ code with F∗ programs via FFI, enabling high-performance, verified systems.
Experimental results
Research questions
- RQ1Can a high-level, formally verified language like F∗ be extended with a low-level subset that supports efficient systems programming while preserving safety and correctness?
- RQ2How can memory safety and side-channel resistance be formally verified in low-level code that manipulates raw memory and pointers?
- RQ3Can verified low-level code achieve performance competitive with unverified C implementations in cryptographic libraries?
- RQ4What is the feasibility of using a shallow embedding in F∗ to build a verified, efficient, and portable low-level programming language?
- RQ5How can formal verification and compilation be combined to produce secure, high-performance systems code from high-level specifications?
Key findings
- Low∗ programs are guaranteed to be memory safe by construction due to F∗'s type system and the structured memory model.
- The compilation pipeline from Low∗ to C preserves both functional correctness and side-channel resistance, as formally proven.
- The performance of Low∗-generated C code is competitive with existing unverified C cryptographic libraries, achieving similar execution times.
- The approach enables seamless integration with F∗ programs via FFI, allowing high-speed, verified systems to be built from verified components.
- The implementation of 28,000 lines of code—including specifications and proofs—demonstrates the scalability of the approach to real-world cryptographic systems.
- The use of KreMLin as a back-end compiler enables predictable, efficient C code generation with formal guarantees.
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.