Skip to content

Commit b5f64e5

Browse files
authored
feat: demo (#17)
1 parent 859e7b3 commit b5f64e5

File tree

16 files changed

+657
-92
lines changed

16 files changed

+657
-92
lines changed

.github/workflows/sync_labels.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
with:
2525
manifest: .github/labels.yaml
26-
prune: false
26+
prune: true

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
target/*
2-
.DS_Store
2+
.DS_Store
3+
*.bytes
4+
proof.meta.json

Cargo.lock

+102-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+32-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,40 @@
11
[workspace]
2-
members =["prover", "frontend"]
2+
members =["prover", "frontend", "demo"]
33
resolver="2"
44

55
[workspace.dependencies]
6-
bellpepper-core ={ version="0.4.0", default-features=false }
76
bellpepper ={ git="https://github.com/argumentcomputer/bellpepper", branch="dev", default-features=false }
8-
ff ={ version="0.13.0", features=["derive"] }
7+
bellpepper-core ={ version="0.4.0", default-features=false }
8+
bincode ="1.3"
9+
bitvec ="1.0"
10+
byteorder ="1.4.3"
11+
cfg-if ="1.0.0"
912
digest ="0.10"
13+
ff ={ version="0.13.0", features=["derive"] }
14+
generic-array ="1.0.0"
15+
group ="0.13.0"
16+
grumpkin-msm ={ git="https://github.com/argumentcomputer/grumpkin-msm", branch="dev" }
1017
halo2curves ={ version="0.6.0", features=["bits", "derive_serde"] }
11-
sha3 ="0.10"
12-
rayon ="1.7"
13-
rand_core ={ version="0.6", default-features=false }
14-
rand_chacha ="0.3"
15-
subtle ="2.5"
18+
hex ="0.4.3"
19+
itertools ="0.13.0" # zip_eq
1620
neptune ={ git="https://github.com/argumentcomputer/neptune", branch="dev", default-features=false }
17-
generic-array ="1.0.0"
1821
num-bigint ={ version="0.4", features=["serde", "rand"] }
19-
num-traits ="0.2"
2022
num-integer ="0.1"
21-
serde ={ version="1.0", features=["derive", "rc"] }
22-
bincode ="1.3"
23-
bitvec ="1.0"
24-
byteorder ="1.4.3"
25-
thiserror ="1.0"
26-
group ="0.13.0"
27-
pairing ="0.23.0"
28-
tracing ="0.1.37"
29-
cfg-if ="1.0.0"
23+
num-traits ="0.2"
3024
once_cell ="1.18.0"
31-
itertools ="0.13.0" # zip_eq
25+
pairing ="0.23.0"
3226
rand ="0.8.5"
27+
rand_chacha ="0.3"
28+
rand_core ={ version="0.6", default-features=false }
29+
rayon ="1.7"
30+
rayon-scan ="0.1.0"
3331
ref-cast ="1.0.20" # allocation-less conversion in multilinear polys # lightens impl macros for pasta
32+
serde ={ version="1.0", features=["derive", "rc"] }
33+
sha3 ="0.10"
3434
static_assertions="1.1.0"
35-
rayon-scan ="0.1.0"
36-
hex ="0.4.3"
37-
38-
# grumpkin-msm has been patched to support MSMs for the pasta curve cycle
39-
# see: https://github.com/argumentcomputer/grumpkin-msm/pull/3
40-
grumpkin-msm={ git="https://github.com/argumentcomputer/grumpkin-msm", branch="dev" }
35+
subtle ="2.5"
36+
thiserror ="1.0"
37+
tracing ="0.1.37"
4138

4239
# wasm32 dependencies
4340
getrandom={ version="0.2.0", default-features=false, features=["js"] }
@@ -49,26 +46,26 @@ proptest="1.2.0"
4946
criterion={ version="0.5", features=["html_reports"] }
5047

5148
# dev dependencies
49+
anyhow ="1.0.72"
50+
expect-test ="1.4.1"
5251
flate2 ="1.0"
52+
handlebars ="5.1.0"
53+
serde_json ="1.0.1"
5354
sha2 ="0.10.7"
54-
tracing-test ={ version="0.2.4", features=["no-env-filter"] }
55-
expect-test ="1.4.1"
56-
anyhow ="1.0.72"
5755
tap ="1.0.1"
58-
tracing-texray ="0.2.0"
5956
tracing-subscriber={ version="0.3.17", features=["env-filter"] }
60-
handlebars ="5.1.0"
61-
serde_json ="1.0.1"
57+
tracing-test ={ version="0.2.4", features=["no-env-filter"] }
58+
tracing-texray ="0.2.0"
6259

6360
[profile.release]
64-
lto =true
6561
codegen-units=1
62+
lto =true
6663
panic ="abort"
6764

6865
[profile.dev]
69-
opt-level =1
66+
codegen-units=256
7067
debug =true
7168
incremental =true
72-
codegen-units=256
7369
lto =false
70+
opt-level =1
7471
panic ="unwind"

README.md

+61-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,67 @@
2222

2323
## Project Structure
2424
The repository contains several key components:
25-
- `edge-frontend`: Frontend adapters for both Noir and Circom
26-
- `edge-prover`: Backend implementation of the client side prover
25+
- `edge-prover`: Backend implementation of Supernova NIVC folding scheme
26+
- `edge-frontend`: Frontend adapters for Noir to use `edge-prover`
27+
- `demo`: A demo application for the `edge-frontend` and `edge-prover`
28+
29+
### Prerequisites
30+
Before running the demo, ensure you have:
31+
1. Rust, Noir, and their associated tools installed
32+
2. The Noir programs compiled to JSON (located in the `target/` directory). To do so, just run
33+
```
34+
nargo compile --workspace
35+
```
36+
from the root directory.
37+
38+
### Running the Demo
39+
The demo application has three main commands: setup, prove, and verify. The help command can be used to see the available options.
40+
```
41+
cargo run -p demo -- --help
42+
```
43+
The demo application proves sequences to a fun (and unproven) math called the Collatz conjecture. In short, for any positive integer `n`, the sequence is defined as:
44+
```
45+
if n is 1, stop.
46+
if n is even, repeat this process on n/2.
47+
if n is odd, repeat this process on 3n + 1.
48+
```
49+
So depending on the starting value, you will find a different sequence of circuits is used to prove the sequence. If you happen to find a case where this proof doesn't work, please let us know -- you may have found a counter example to the conjecture! 😁
50+
51+
#### 1. Setup Phase
52+
First, run the offline setup phase:
53+
```
54+
cargo run -p demo -- setup
55+
```
56+
This will create a `setup.bytes` file in the current directory. You can specify an output file name as an argument (see help for more details).
57+
58+
#### 2. Prove Phase
59+
Generate a proof for a specific input value (e.g., 42):
60+
```
61+
cargo run -p demo -- prove --input 42
62+
```
63+
This creates:
64+
- `proof.bytes`: The compressed proof
65+
- `proof.meta.json`: Metadata about the proof, including:
66+
- The input value
67+
- Number of steps in the Collatz sequence
68+
- The complete sequence of even/odd operations
69+
If you'd like, you can run with some logging to see the steps:
70+
```
71+
cargo run -p demo -- prove --input 42 -v
72+
```
73+
and to see more logs, you can use `-vv` or `-vvv`.
74+
75+
#### 3. Verify Phase
76+
To verify a proof, run:
77+
```
78+
cargo run -p demo -- verify --input 42
79+
```
80+
This will verify the proof. Without verbosity, no output implies a valid proof. But if you provided an incorrect input, you will see an error message. For example, if you provide an input of 43, you will see:
81+
```
82+
ERROR demo: ❌ Proof verification failed: NovaError
83+
Error: NovaError(ProofVerifyError)
84+
```
85+
2786

2887
## Usage
2988
This repository and its crates are **not** production ready. Do not use them in production. No audits have been done and none are planned.

demo/Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
edition="2021"
3+
name ="demo"
4+
version="0.1.0"
5+
6+
[dependencies]
7+
bincode ={ workspace=true }
8+
clap ={ version="4.5", features=["derive"] }
9+
edge-frontend ={ path="../frontend", features=["demo"] }
10+
serde_json ={ workspace=true }
11+
tracing ={ workspace=true }
12+
tracing-subscriber={ workspace=true }

0 commit comments

Comments
 (0)