Extracting Smart Contracts Tested and Verified in Coq
We implement extraction of Coq programs to functional languages based on MetaCoq’s certified erasure. As part of this, we implement an optimization pass to remove unused arguments of functions and constructors, making integration with the (often polymorphic) extracted code easier. This pass is proven correct over a weak call by value operational semantics that fits well with many functional languages. We argue that our extraction pipeline applies generally to these functional languages with a small trusted computing base of only MetaCoq and the pretty-printers into these languages. We apply this to two functional smart contract languages, Liquidity and Midlang, which are respectively similar to Ocaml and Elm. This is done in the context of the ConCert framework that allows proving properties of functional smart contracts. The extraction is exemplified by several programs, including a smart contract that uses dependent types, showing that we are able to handle non-trivial programs. We also contribute a verified boardroom voting smart contract featuring maximum voter privacy such that each vote is kept private except under collusion of all other parties. With ConCert’s executable specification our contracts are furthermore fully testable from within Coq. This enables us to integrate property-based testing into ConCert using QuickChick. We show that this is successful by testing complex contracts such as the congress contract (the essence of TheDAO), an escrow contract, an implementation of a Decentralized Finance (DeFi) contract which includes a custom token standard (Tezos FA2), and more. In total, this gives us a way to write dependent programs in Coq, test them semi-automatically, verify them, and then extract them to functional smart contract languages, while retaining a small TCB.
Presentation Slides (extracting-smart-contracts-CPP2021.pdf) | 629KiB |
Mon 18 JanDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
18:45 - 19:30 | Security, Blockchains, and Smart ContractsCPP at CPP Chair(s): Andreas Lochbihler Digital Asset Streamed session: https://youtu.be/Qak5mK92etU?t=2832 | ||
18:45 15mTalk | Extracting Smart Contracts Tested and Verified in Coq CPP Danil Annenkov Concordium Blockchain Research Center, Aarhus University, Mikkel Milo Concordium Blockchain Research Center, Aarhus University, Jakob Botsch Nielsen Concordium Blockchain Research Center, Aarhus University, Bas Spitters Concordium Blockchain Research Center, Aarhus University Pre-print Media Attached File Attached | ||
19:00 15mTalk | Formal Verification of Authenticated, Append-Only Skip Lists in Agda CPP Victor Cacciari Miraldo DFINITY Foundation, Harold Carr Oracle Labs, USA, Mark Moir Oracle Labs, New Zealand, Lisandra Silva University of Minho, Guy L. Steele Jr. Oracle Labs Pre-print Media Attached | ||
19:15 15mTalk | Towards formally verified compilation of tag-based policy enforcement CPP CHR Chhak Portland State University, Andrew Tolmach Portland State University, Sean Anderson Portland State University Pre-print Media Attached |