Skip to content

Commit 62916e5

Browse files
authored
chore: Formal Specification for the Merkle Tree circuits (#1033)
* initial version of rangecheck correctness * optimize range check and clean up correctness proof * formalize insertion circuit * finish merkle lemmas * combined circuit proofs
1 parent 2b4a6fa commit 62916e5

28 files changed

+1114
-3852
lines changed

.github/workflows/prover-test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ jobs:
3434
with:
3535
go-version-file: "./light-prover/go.mod"
3636

37+
- name: Install Elan
38+
run: |
39+
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y -v --default-toolchain leanprover/lean4:v4.2.0
40+
echo "LAKE_VERSION=$(~/.elan/bin/lake --version)" >> "$GITHUB_ENV"
41+
42+
- name: Cache dependencies
43+
uses: actions/cache@v3
44+
with:
45+
path: light-prover/formal-verification/lake-packages
46+
key: "${{ env.LAKE_VERSION }}"
47+
3748
- name: Download keys
3849
run: |
3950
cd light-prover
@@ -53,3 +64,14 @@ jobs:
5364
run: |
5465
cd light-prover
5566
go test -timeout 30m
67+
68+
- name: Extract circuit to Lean
69+
run: |
70+
cd light-prover
71+
./light-prover extract-circuit --output formal-verification/FormalVerification/Circuit.lean --tree-depth=26 --compressed-accounts=8
72+
73+
- name: Build lean project
74+
run: |
75+
cd light-prover/formal-verification
76+
~/.elan/bin/lake exe cache get
77+
~/.elan/bin/lake build

light-prover/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This part explains the existing cli commands.
5151
Flags:
5252
1. output *file path* - File to be writen to
5353
2. tree-depth *n* - Merkle tree depth
54-
3. batch-size *n* - Batch size for Merkle tree updates
54+
3. compressed-accounts *n* - number of COMPRESSED_ACCOUNTs
5555

5656
## Running
5757

@@ -123,4 +123,13 @@ light-prover:
123123

124124
docker compose build
125125
docker compose up -d
126-
```
126+
```
127+
128+
## Formal Verification
129+
130+
1. Install [Elan](https://github.com/leanprover/elan).
131+
2. ```
132+
cd formal-verification
133+
lake exe cache get # optional, but speeds up dependency compilation
134+
lake build # compiles and checks the theorems
135+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lakefile.olean

light-prover/formal-verification/FormalVerification.lean

Lines changed: 0 additions & 1665 deletions
This file was deleted.

light-prover/formal-verification/FormalVerification/BinaryDecompositions.lean

Lines changed: 0 additions & 72 deletions
This file was deleted.

light-prover/formal-verification/FormalVerification/Circuit.lean

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.

light-prover/formal-verification/FormalVerification/Common.lean

Lines changed: 0 additions & 12 deletions
This file was deleted.

light-prover/formal-verification/FormalVerification/Deletion.lean

Lines changed: 0 additions & 206 deletions
This file was deleted.

0 commit comments

Comments
 (0)