Skip to content

Commit 6eea609

Browse files
adding sp1 crate
1 parent fcbb881 commit 6eea609

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

Cargo.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ members = [
2020
"crates/nova",
2121
"crates/groth16",
2222
"crates/errors",
23+
"crates/sp1",
24+
]
25+
default-members = [
26+
"crates/prism",
27+
"crates/common",
28+
"crates/nova",
29+
"crates/groth16",
30+
"crates/errors",
2331
]
2432
resolver = "2"
2533

@@ -68,11 +76,13 @@ sha2 = "0.10.8"
6876
auto_impl = "1.2.0"
6977
bincode = "1.3.3"
7078
blake2 = "0.10.6"
79+
sp1-zkvm = { version = "1.2.0" }
7180
prism-common = { path = "crates/common" }
7281
prism-nova = { path = "crates/nova" }
7382
prism-errors = { path = "crates/errors" }
7483
prism-main = { path = "crates/prism" }
7584
prism-groth16 = { path = "crates/groth16" }
85+
sp1-helper = "1.2.0"
7686

7787
[patch.crates-io]
7888
sha2-v0-9-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.9.8" }

crates/sp1/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "prism-sp1"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
9+
[dependencies]
10+
prism-common = { workspace = true }
11+
sp1-zkvm = { workspace = true }

crates/sp1/src/main.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![no_main]
2+
sp1_zkvm::entrypoint!(main);
3+
4+
use prism_common::tree::{Batch, Digest, Proof};
5+
6+
pub fn main() {
7+
println!("cycle-tracker-start: setup");
8+
let batch = sp1_zkvm::io::read::<Batch>();
9+
let mut current = batch.prev_root;
10+
println!("cycle-tracker-end: setup");
11+
12+
println!("cycle-tracker-start: proof-iteration");
13+
for proof in batch.proofs.iter() {
14+
match proof {
15+
Proof::Update(p) => {
16+
assert_eq!(current, Digest::new(p.old_root.into()));
17+
println!("cycle-tracker-start: update");
18+
assert!(p.verify().is_ok());
19+
println!("cycle-tracker-end: update");
20+
current = Digest::new(p.new_root.into());
21+
}
22+
Proof::Insert(p) => {
23+
assert_eq!(current, p.non_membership_proof.root);
24+
println!("cycle-tracker-start: insert");
25+
assert!(p.verify().is_ok());
26+
println!("cycle-tracker-end: insert");
27+
current = p.new_root;
28+
}
29+
}
30+
}
31+
println!("cycle-tracker-end: proof-iteration");
32+
33+
sp1_zkvm::io::commit_slice(&current.to_bytes());
34+
}

rust-toolchain

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "1.79.0"
3+
components = ["llvm-tools", "rustc-dev"]

0 commit comments

Comments
 (0)