Smart-contract formal verification

Prove your contracts behave as specified.

A specification states what a function must do. CertiK Prover checks that statement against your Solidity code for every allowed input and starting state within a stated scope, which no set of test cases can show on its own.

03_mint_invariant.sol4Proven1Failed1Inconclusive

Cases

function
mint(address to, uint amount)
//@ invariant \sum_of(balance) == totalSupply;
//@ assignable balance[to], totalSupply;
function mint(address to, uint amount) public {
balance[to] += amount;
totalSupply += amount;
}

Property

mint() should preserve equality between total supply and the sum of all account balances.

  1. Spec crafting
  2. Source parsed
  3. Constraints generated
  4. Automated prover
    Proven
Supply stays consistent
Total supply matches the sum of all account balances.

Tests and proofs

A test checks the cases you wrote. A proof checks every case in scope.

Example-based test
Runs chosen inputs from a chosen starting state and checks the observed execution.Evidence for the cases that were executed.
CertiK Prover obligation
Reasons about the allowed inputs and starting states in the confirmed task, and checks whether the selected property follows from the code.A general claim within the stated scope, not a claim about unspecified behavior.

Capabilities

Claims range from one call to a whole scenario.

Each level below is a kind of claim CertiK Prover can check. Choose the smallest one that states your property; a verification task may combine several.

Specification
//@ ensures balance == \old(balance) - amount;
//@ ensures \result == balance;
//@ assignable balance;
//@ reverts_when amount > balance;
//@ reverts_only_when amount > balance;

Function

function withdraw(uint256 amount) public returns (uint256);
A withdrawal lowers the balance by exactly the amount, and reverts only when the amount exceeds the balance.

Industry standards

The highest assurance levels point to formal verification.

Security standards reserve their strongest assurance for mathematical proof. CertiK Prover brings that method to your Solidity code.