paperbot · PL 论文追踪

全部论文 待读 收藏

P2 CryptOpt: Verified Compilation with Randomized Program Search for Cryptographic Primitives

CryptOpt:面向密码原语的随机程序搜索与验证编译
PLDI 7(PLDI)2023匹配度 2/10 · 该论文聚焦密码原语的经过验证的编译、随机搜索与 Coq 机器化证明,属于编译器/程序合成/定理证明方向;与用户核心关注的静态分析、LLM/Agent 交叉、浮点程序分析或贝叶斯程序分析没有直接关系,仅形式化验证与程序合成有边缘关联。引用 12 inbox
Joel Kuepper, Andres Erbsen, Jason Gross, Owen Conoly, Chuyue Sun, Samuel Tian, David Wu, Adam Chlipala, Chitchanok Chuengsatiansup, Daniel Genkin, Markus Wagner, Yuval Yarom
crossref: 2026-09-10

AI 速览

一句话:首个将高层密码函数式程序编译为汇编的流水线,通过随机搜索与 Coq 机器化证明,生成比 GCC/Clang 更快的代码。

密码学中许多性能关键例程长期以手写汇编实现,已有工作或对汇编做形式验证,或自动生成带证明的 C 代码,但性能不如最佳手工汇编。本文提出 CryptOpt,一个将高层密码函数式程序特化为汇编代码的编译流水线。优化侧,它在汇编程序空间中进行随机搜索,并在目标 CPU 上反复自动基准测试以挑选最优实现;验证侧,它接入 Fiat Cryptography 框架(该框架把函数式程序翻译为类 C 的 IR),并新增一个经形式验证的程序等价检查器,内嵌 SMT 求解器与符号执行引擎的部分机制。最终机器化证明(Coq)的定理只涉及输入函数式程序与 x86-64 汇编的操作语义。原型系统实用性强,为 TLS 标准中的 Curve25519 与比特币椭圆曲线 secp256k1 在 Intel 第 12、13 代处理器上生成了新的最快已知有限域算术实现。

问题
密码学性能关键例程常直接手写汇编,既缺乏形式验证保证,而已有的自动生成方案又比最佳手工汇编慢。
方法
构建 CryptOpt 编译流水线:在汇编程序空间做随机搜索并结合目标 CPU 实测,同时接入 Fiat Cryptography 并扩展一个经 Coq 形式验证的程序等价检查器。
评估
以 Curve25519 与 secp256k1 的有限域算术为基准,在 Intel 第 12、13 代 CPU 上与 GCC/Clang 及已知最优实现比较性能,并给出机器化验证的定理陈述。
原文摘要(Abstract)

Most software domains rely on compilers to translate high-level code to multiple different machine languages, with performance not too much worse than what developers would have the patience to write directly in assembly language. However, cryptography has been an exception, where many performance-critical routines have been written directly in assembly (sometimes through metaprogramming layers). Some past work has shown how to do formal verification of that assembly, and other work has shown how to generate C code automatically along with formal proof, but with consequent performance penalties vs. the best- known assembly. We present CryptOpt, the first compilation pipeline that specializes high-level cryptographic functional programs into assembly code significantly faster than what GCC or Clang produce, with mechanized proof (in Coq) whose final theorem statement mentions little beyond the input functional program and the operational semantics of x86-64 assembly. On the optimization side, we apply randomized search through the space of assembly programs, with repeated automatic benchmarking on target CPUs. On the formal-verification side, we connect to the Fiat Cryptography framework (which translates functional programs into C-like IR code) and extend it with a new formally verified program-equivalence checker, incorporating a modest subset of known features of SMT solvers and symbolic-execution engines. The overall prototype is quite practical, e.g. producing new fastest-known implementations of finite-field arithmetic for both Curve25519 (part of the TLS standard) and the Bitcoin elliptic curve secp256k1 for the Intel 12𝑡ℎ and 13𝑡ℎ generations.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1998,
  title = {CryptOpt: Verified Compilation with Randomized Program Search for Cryptographic Primitives},
  author = {Joel Kuepper and Andres Erbsen and Jason Gross and Owen Conoly and Chuyue Sun and Samuel Tian and David Wu and Adam Chlipala and Chitchanok Chuengsatiansup and Daniel Genkin and Markus Wagner and Yuval Yarom},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {PLDI},
  year = {2023},
  doi = {10.1145/3591272}
}