[论文解读] Verified Low-Level Programming Embedded in F*
本文提出 Low∗,一种嵌入在 F∗ 中的经过形式化验证的低级编程语言,支持高效、内存安全的系统编程,并具备形式化验证能力。通过结合 F∗ 的依赖类型与验证能力,以及类似 CompCert 的内存模型,Low∗ 可编译为高效、抗侧信道攻击的 C 代码,在保证正确性与安全性的前提下,性能可与未经验证的 C 库相媲美,且通过机器可检查的证明实现形式化保障。
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.
研究动机与目标
- 弥合高级、形式化验证代码与低级、高性能系统代码之间的差距。
- 解决由内存安全违规(如缓冲区溢出)导致的密码学软件安全漏洞。
- 实现高效、经验证的密码学算法实现,性能可与未经验证的 C 代码相媲美。
- 提供从高级规格说明到高效、安全 C 代码的端到端形式化验证编译管道。
提出的方法
- 通过受控嵌入方式,将类似 C 的低级代码子集嵌入 F∗,采用受 CompCert 启发的结构化内存模型。
- 利用 F∗ 的依赖类型与精炼类型,精确表达规格说明,并证明功能正确性与内存安全性。
- 实现自定义后端编译器 KreMLin,将 Low∗ 代码转换为高效、可预测的 C 代码。
- 在代码提取阶段擦除证明与规格说明,生成优化后的、可投入生产的 C 代码。
- 通过形式化验证编译过程与内存模型,确保侧信道抵抗能力。
- 通过 FFI 与 F∗ 程序集成 Low∗ 代码,实现高性能、经验证的系统构建。
实验结果
研究问题
- RQ1能否在类似 F∗ 的高级、形式化验证语言中扩展出一个低级子集,使其支持高效系统编程,同时保持安全与正确性?
- RQ2如何在操纵原始内存与指针的低级代码中,形式化验证内存安全与侧信道抵抗能力?
- RQ3经验证的低级代码能否在性能上与未经验证的 C 实现相媲美,特别是在密码学库中?
- RQ4在 F∗ 中采用浅层嵌入是否可行,以构建一个经验证、高效且可移植的低级编程语言?
- RQ5如何将形式化验证与编译过程结合,从高级规格说明生成安全、高性能的系统代码?
主要发现
- 由于 F∗ 的类型系统与结构化内存模型,Low∗ 程序从构造之初即保证内存安全。
- 从 Low∗ 到 C 的编译管道在形式上证明保留了功能正确性与侧信道抵抗能力。
- Low∗ 生成的 C 代码性能与现有未经验证的 C 密码学库相当,执行时间相近。
- 该方法可通过 FFI 与 F∗ 程序无缝集成,支持使用经验证组件构建高速、经验证的系统。
- 实现 28,000 行代码(含规格说明与证明)表明该方法可扩展至真实世界的密码学系统。
- 使用 KreMLin 作为后端编译器,可生成可预测、高效的 C 代码,并附带形式化保证。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。