A framework for smart contract verification in Coq.
See the Papers for details on the development. ConCert can find real-world attacks as explained here, here, and here.
Our development works with Coq 8.17 and depends on MetaCoq, and std++.
The tests depend on QuickChick.
The dependencies can be installed through opam
.
Branches compatible with older versions of Coq can be found here.
Installing the necessary dependencies requires the opam package manager and a switch with Coq 8.17 installed. If you don't already have a switch set up run the following commands
opam switch create . 4.10.2 --repositories default,coq-released=https://coq.inria.fr/opam/released
eval $(opam env)
To install the dependencies run
git clone https://github.com/AU-COBRA/ConCert.git
cd ConCert
opam install ./coq-concert.opam --deps-only
After completing the procedures above, run make
to build the development, and make html
to build the documentation.
The documentation will be located in the docs
folder after make html
.
Example smart contracts can be built by running make examples
.
To install ConCert in your switch run
git clone https://github.com/AU-COBRA/ConCert.git
cd ConCert
opam install ./coq-concert.opam
Examples can be installed by running
git clone https://github.com/AU-COBRA/ConCert.git
cd ConCert
opam install ./coq-concert.opam --with-test
Each folder contains a separate README file with more details.
The embedding folder contains the development of the verified embedding of λsmart
to Coq.
The execution folder contains the formalization of the smart contract execution layer, which allows reasoning about interacting contracts, and perform property-based testing. The test folder contains the property-based testing framework. The key generators used for automatically generating blockchain execution traces for testing can be found in TraceGens.v. The testing framework was developed as part of a Master's Thesis at Aarhus University, and the thesis detailing (an earlier state of) the development can be found here.
The extraction folder contains an extraction pipeline for smart contract languages. Currently, we support smart contract languages Liquidity and CameLIGO, and general-purpose languages Elm and Rust as targets. Pretty-printers to these languages are implemented directly in Coq. One can also obtain an OCaml plugin for Coq by extracting our pipeline using the standard extraction of Coq (currently, it is possible for extraction to Rust).
The examples folder contains examples of smart contract implementations, embedding, extraction, and tests. Extracted smart contracts can be found here.
The project consists of four subprojects: embedding
, execution
, extraction
,
and examples
located in the corresponding folders.
Each subproject has its own _CoqProject
file and Makefile
.
The Makefile
in the root folder dispatches the calls to the corresponding subproject.
The project documentation in HTML format is generated for each build. We use the standard Coqdoc with improved styles and scripts of CoqdocJS (license) and local table of contents by TOC(license).
"Extracting functional programs from Coq, in Coq".
Danil Annenkov, Mikkel Milo, Jakob Botsch Nielsen, Bas Spitters.
Journal of Functional Programming (JFP), Volume 32, 2022, e11. DOI: 10.1017/S0956796822000077
"Finding Smart Contract Vulnerabilities with ConCert’s Property-Based Testing Framework".
Mikkel Milo, Eske Hoy Nielsen, Danil Annenkov, and Bas Spitters.
FMBC 2022.
"Formalising Decentralised Exchanges in Coq".
Eske Hoy Nielsen, Danil Annenkov and Bas Spitters.
CPP 2023.
"Code Extraction from Coq to ML-like languages".
Danil Annenkov, Mikkel Milo and Bas Spitters.
"ML'21" at ICFP'21.
"Extending MetaCoq Erasure: Extraction to Rust and Elm".
Danil Annenkov, Mikkel Milo, Jakob Botsch Nielsen, and Bas Spitters.
Extended abstract. The Coq Workshop 2021.
"Extracting Smart Contracts Tested and Verified in Coq".
Danil Annenkov, Mikkel Milo, Jakob Botsch Nielsen, Bas Spitters.
CPP'21.
"Verifying, testing and running smart contracts in ConCert".
Danil Annenkov, Mikkel Milo, Jakob Botsch Nielsen, Bas Spitters.
Coq Workshop 2020.
"ConCert: A Smart Contract Certification Framework in Coq".
Danil Annenkov, Jakob Botsch Nielsen, Bas Spitters.
CPP 2020.
"Smart Contract Interactions in Coq".
Jakob Botsch Nielsen, Bas Spitters.
1st Workshop on Formal Methods for Blockchains, 3rd Formal Methods World Congress, October 2019.
A video collection, presenting various parts of ConCert can be found on YouTube.