Skip to main navigation Skip to search Skip to main content

CryptOpt: Verified compilation with randomized program search for cryptographic primitives

  • Joel Kuepper
  • , Andres Erbsen
  • , Jason Gross
  • , Owen Conoly
  • , Chuyue Sun
  • , Samuel Tian
  • , David Wu
  • , Adam Chlipala
  • , Chitchanok Chuengsatiansup
  • , Daniel Genkin
  • , Markus Wagner
  • , Yuval Yarom

Research output: Chapter in Book/Report/Conference proceedingConference PaperResearchpeer-review

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 12g and 13g generations.

Original languageEnglish
Title of host publicationProceedings of the ACM on Programming Languages
Subtitle of host publicationProgramming Language Design and Implementation (PLDI 2023)
EditorsDame Wendy Hall, Divesh Srivastava
Place of PublicationNew York NY USA
PublisherAssociation for Computing Machinery (ACM)
Number of pages25
DOIs
Publication statusPublished - 2023
EventACM SIGPLAN Conference on Programming Language Design and Implementation 2023 - Orlando, United States of America
Duration: 17 Jun 202321 Jul 2023
Conference number: 44th
https://pldi23.sigplan.org/ (Website)
https://dl.acm.org/toc/pacmpl/2023/7/PLDI (Proceedings)

Publication series

NameProceedings of the ACM on Programming Languages
PublisherAssociation for Computing Machinery (ACM)
Volume7
ISSN (Print)2475-1421

Conference

ConferenceACM SIGPLAN Conference on Programming Language Design and Implementation 2023
Abbreviated titlePLDI 2023
Country/TerritoryUnited States of America
CityOrlando
Period17/06/2321/07/23
Internet address

Keywords

  • assembly
  • elliptic-curve cryptography
  • search-based software engineering

Cite this