CryptOpt: Verified Compilation with Randomized Program Search for Cryptographic Primitives (full version)

Joel Kuepper, Andres Erbsen, Jason Gross, Owen Conoly, Chuyue Sun +7 more
11/19/2022
cs.CRcs.NEcs.PL

Official code: 0xADE1A1DE/CryptOpt (73 stars, TypeScript, Apache-2.0, last commit 2024-06-26).

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).

Show full abstract

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^{th}$ and $13^{th}$ generations.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

CryptOpt: Verified Compilation with Randomized Program Search for Cryptographic Primitives

7315TypeScript, AssemblyJul 20, 20222 years agoApache-2.0

Similar Papers

Cite this paper

@article{kuepper2022cryptopt,
  title  = {CryptOpt: Verified Compilation with Randomized Program Search for Cryptographic Primitives (full version)},
  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},
  year   = {2022},
  eprint = {2211.10665},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2211.10665}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2211.10665.svg)](https://codeofpaper.com/paper/2211.10665)

Discussion