This project provides a symbolic cryptography library in Lean, together with a formally verified computational soundness theorem and a formally verified symbolic proof of security for the garbled circuit scheme (based on [LM18]).
This repository accompanies the paper:
Computationally-Sound Symbolic Cryptography in Lean
S. Dziembowski, G. Fabiański, D. Micciancio, and R. Stefański
(accepted to CSF 2026; a preprint available at Cryptology ePrint Archive)
We recommend reading the paper as it provides the high-level overview and the intuition behind the formalization.
To build the project (i.e. to verify the proofs), run lake build from the root directory of this repository.
Below is a brief description of the main files in this directory, along with their dependencies.
Our project depends on the VCVio library, introduced in [TH24], to define computations that can query an oracle. The VCVio2 folder contains a fragment of this library, specifically the part that defines such computations. We had some troubles building the original library, so
we have modified the original code by removing parts that we did not need for our project, and making small fixes to make it compatible with our versions of Lean and Mathlib.
This folder defines computational indistinguishability and develops some basic properties.
Def.leandefines computational indistinguishability between two oracles. It also defines indistinguishability between two families of distributions. These definitions rely on an abstract notion of complexity which captures all allowed adversarial behavior(called PolynomialTime, as commonly assumed in cryptography). For more details, see our paper.Lemmas.leanproves basic properties of indistinguishability, such as transitivity and symmetry. It also includes the lemmaIndistinguishabilityByReduction, which shows how to use reductions to prove indistinguishability.
This folder contains general mathematical results used in the project:
Fixpoints.leanproves a constructive version of the Knaster–Tarski theorem, showing the existence of fixpoints in a lattice of finite sets.CardinalityLemmas.leancontains auxiliary lemmas about the cardinality of sets.
This module defines the expression language used in symbolic cryptography, based on [LM18]:
Defs.leandefines expressions (typeExpression).Renamings.leandefines the valid variable renaming.SymbolicIndistinguishability.leandefines symbolic indistinguishability between expressions (in particular it defines thenormalizeExprfunction that computes the normal form of an expression, andadversaryViewwhich hides the parts of an expression that are not available to the adversary).
The Expression/Lemmas submodule contains various auxiliary lemmas:
NormalizeIdempotent.leanproves that expression normalization is idempotent.Renaming.leancontains lemmas about commuting renaming and normalization.HideEncrypted.leanfocuses on properties ofadversaryKeys, such as bounds and dependence only on the keys used in an expression.
The Expression/ComputationalSemantics submodule contains the following files:
Def.leandefines the computational semantics of an expression, i.e. a function that maps an expression (and an encryption scheme) to a distribution over bitstrings.NormalizePreserves.leanandRenamePreserves.leanprove that normalization and renaming do not change the computational semantics.EncryptionIndCpa.leandefines the notion of IND-CPA security for encryption schemes.Soundness.leanproves the soundness theorem: if two expressions are symbolically indistinguishable, then their computational semantics (distributions over bitstrings) are computationally indistinguishable. The technical details of this proof are inSoundnessProof.
This showcases the symbolic approach to cryptography by proving the security of a garbled circuit scheme (following the lines of [LM18]). Thanks to the soundness theorem, this boils down to proving symbolic indistinguishability.
Circuits.lean– Defines circuits inductively. The main definitions are theCircuittype and theevalCircuitfunction.GarblingDef.lean– Defines the garbling scheme. The main definitions are:Garble: garbles the circuit,GEval: evaluates the garbled circuit symbolically.
Simulation.lean– Defines the simulation procedure (SimulateG), used to establish the security of garbling.Security.lean– Proves the security of the garbling scheme. Thanks to the soundness theorem, the main goal here is to prove symbolic indistinguishability. The main lemma isgarblingSecure.Correctness.lean– Proves the correctness of the garbling scheme at the symbolic level. The main lemma isgarbleCorrect.
The proof of symbolic security depends on the results from SymbolicHiding/ submodule:
GarbleProof.leancharacterizes the output ofadversaryKeys garbledCircuit.GarbleHole.leancharacterizes the output ofadversaryView garbledCircuit.SimulateProof.leananalogous toGarbleProof.leanandGarbleHole.lean, but for the simulated garbled circuit.GarbleHoleBitSwap.leanconstructs explicitly a variable renaming maps from the actual garbled circuit to the simulated one.
[LM18]: Li, Baiyu, and Daniele Micciancio. "Symbolic security of garbled circuits." 2018 IEEE 31st Computer Security Foundations Symposium (CSF). IEEE, 2018. [TH24] Devon Tuma and Nicholas Hopper. 2024. VCVio: A Formally Verified Forking Lemma and Fiat-Shamir Transform, via a Flexible and Expressive Oracle Representation. IACR Cryptol. ePrint Arch. (2024), 1819. https://eprint.iacr.org/2024/1819
This project is distributed under the MIT License.
However, the VCVio2/ directory contains modified code from the
VCVio library, introduced in [TH24], which is
licensed under the Apache License 2.0 (see VCVio2/LICENSE-APACHE).