Skip to content

Commit 4aa0e46

Browse files
committed
refactor: rename libs and functions
1 parent 0a46e9c commit 4aa0e46

File tree

11 files changed

+40
-48
lines changed

11 files changed

+40
-48
lines changed

aggregation-mode/Cargo.lock

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

aggregation-mode/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
sp1-sdk = "4.1.3"
8-
zkvm_sp1_interface = { path = "./zkvm/sp1/", package = "sp1_verifier_program" }
8+
sp1_aggregator = { path = "./zkvm/sp1/" }
99
serde = { version = "1.0.203", features = ["derive"] }
1010
serde_json = "1.0.117"
1111
tracing = { version = "0.1", features = ["log"] }

aggregation-mode/src/verifiers/interface.rs renamed to aggregation-mode/src/aggregator/interface.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::sp1::{self, SP1AggregatedProof};
22
use serde::{Deserialize, Serialize};
3-
use zkvm_sp1_interface::SP1CompressedProof;
3+
use sp1_aggregator::SP1CompressedProof;
44

55
#[derive(Serialize, Deserialize)]
66
pub enum InputProofs {
@@ -13,10 +13,8 @@ pub struct ProgramInput {
1313
}
1414

1515
impl ProgramInput {
16-
pub fn new(input_proofs: InputProofs) -> Self {
17-
ProgramInput {
18-
proofs: input_proofs,
19-
}
16+
pub fn new(proofs: InputProofs) -> Self {
17+
ProgramInput { proofs }
2018
}
2119
}
2220

@@ -26,12 +24,11 @@ pub enum AggregatedProof {
2624

2725
pub struct ProgramOutput {
2826
pub proof: AggregatedProof,
29-
pub leaves: Vec<Vec<u8>>,
3027
}
3128

3229
impl ProgramOutput {
33-
pub fn new(proof: AggregatedProof, leaves: Vec<Vec<u8>>) -> Self {
34-
Self { proof, leaves }
30+
pub fn new(proof: AggregatedProof) -> Self {
31+
Self { proof }
3532
}
3633

3734
/// TODO: return the contract calldata to verify proof
@@ -46,8 +43,8 @@ pub enum AggregatedVerificationError {
4643
SP1Proving,
4744
}
4845

49-
pub fn verify_proofs(input: ProgramInput) -> Result<ProgramOutput, AggregatedVerificationError> {
46+
pub fn aggregate_proofs(input: ProgramInput) -> Result<ProgramOutput, AggregatedVerificationError> {
5047
match input.proofs {
51-
InputProofs::SP1Compressed(proofs) => sp1::verify_proof_aggregation(proofs),
48+
InputProofs::SP1Compressed(proofs) => sp1::aggregate_proofs(proofs),
5249
}
5350
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
use sp1_aggregator::SP1CompressedProof;
12
use sp1_sdk::{ProverClient, SP1ProofWithPublicValues, SP1Stdin, SP1VerifyingKey};
2-
use zkvm_sp1_interface::SP1CompressedProof;
33

44
use super::interface::{AggregatedProof, AggregatedVerificationError, ProgramOutput};
55

6-
const PROGRAM_ELF: &[u8] = include_bytes!("../../zkvm/sp1/elf/sp1_verifier_program");
6+
const PROGRAM_ELF: &[u8] = include_bytes!("../../zkvm/sp1/elf/sp1_aggregator_program");
77

88
pub struct SP1AggregatedProof {
99
proof: SP1ProofWithPublicValues,
1010
vk: SP1VerifyingKey,
1111
}
1212

13-
pub(crate) fn verify_proof_aggregation(
13+
pub(crate) fn aggregate_proofs(
1414
proofs: Vec<SP1CompressedProof>,
1515
) -> Result<ProgramOutput, AggregatedVerificationError> {
1616
let mut stdin = SP1Stdin::new();
@@ -29,10 +29,7 @@ pub(crate) fn verify_proof_aggregation(
2929
.verify(&proof, &vk)
3030
.map_err(AggregatedVerificationError::SP1Verification)?;
3131

32-
let output = ProgramOutput::new(
33-
AggregatedProof::SP1(SP1AggregatedProof { proof, vk }),
34-
vec![],
35-
);
32+
let output = ProgramOutput::new(AggregatedProof::SP1(SP1AggregatedProof { proof, vk }));
3633

3734
Ok(output)
3835
}

aggregation-mode/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
mod verifiers;
1+
mod aggregator;
22

3-
use verifiers::interface::{
4-
verify_proofs, AggregatedVerificationError, InputProofs, ProgramInput, ProgramOutput,
3+
pub use aggregator::interface::{
4+
aggregate_proofs, AggregatedVerificationError, InputProofs, ProgramInput, ProgramOutput,
55
};
6-
7-
pub fn verify_aggregated_proofs() -> Result<ProgramOutput, AggregatedVerificationError> {
8-
let sp1_compressed_proofs = vec![];
9-
let input = ProgramInput::new(InputProofs::SP1Compressed(sp1_compressed_proofs));
10-
verify_proofs(input)
11-
}

aggregation-mode/src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
use std::time::Duration;
22

3-
use proof_aggregator::verify_aggregated_proofs;
3+
use proof_aggregator::{aggregate_proofs, InputProofs, ProgramInput};
44
use tracing::{error, info};
55
use tracing_subscriber::FmtSubscriber;
66

77
fn main() {
88
let subscriber = FmtSubscriber::builder().finish();
99
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
1010

11-
// simulate a service that sends proofs every n seconds after some processing
11+
// simulate a service that aggregates proofs every n seconds after some processing
1212
loop {
1313
info!("Waiting 2 seconds before aggregating proofs...");
1414
std::thread::sleep(Duration::from_secs(2));
1515

16-
let Ok(output) = verify_aggregated_proofs() else {
16+
let proofs = InputProofs::SP1Compressed(vec![]);
17+
let input = ProgramInput::new(proofs);
18+
let Ok(output) = aggregate_proofs(input) else {
1719
error!("Error while aggregating and verifying proofs");
1820
return;
1921
};
22+
2023
info!("Proof aggregated, sending to aligned verification contract...");
2124

2225
// TODO: send a blob transaction to with the merkle leaves
23-
let _leaves = &output.leaves;
24-
25-
// TODO: call contract to verify proof + attach blob transaction
26+
// TODO: call contract to verify proof + attach blob transaction root
2627
// the contract should emit a log with the verification and the path to the blob
2728
let _calldata = output.calldata();
2829
}

aggregation-mode/zkvm/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregation-mode/zkvm/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[workspace]
2-
name = "zkvm"
2+
name = "zkvm_aggregators"
33
version = "0.1.0"
44
edition = "2021"
55
resolver = "2"
66
members = ["sp1"]
77

88
[workspace.dependencies]
9+
serde = { version = "1.0.203", features = ["derive"] }
10+
serde_json = "1.0.117"
11+
sha2 = "0.10.8"
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
2-
name = "sp1_verifier_program"
2+
name = "sp1_aggregator"
33
version = "0.1.0"
44
edition = "2021"
55
resolver = "2"
66

77
[dependencies]
88
sp1-zkvm = { version = "4.1.3", features = ["verify"] }
9-
sha2 = "0.10.8"
10-
serde = { version = "1.0.203", features = ["derive"] }
11-
serde_json = "1.0.117"
9+
serde = { workspace = true }
10+
serde_json = { workspace = true }
11+
sha2 = { workspace = true }
1212

1313
[patch.crates-io]
1414
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", tag = "sha2-v0.10.8-patch-v1" }
@@ -17,5 +17,5 @@ sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", tag = "sha2-v
1717
path = "./src/lib.rs"
1818

1919
[[bin]]
20-
name = "sp1_verifier_program"
21-
path = "src/main.rs"
20+
name = "sp1_aggregator_program"
21+
path = "./src/main.rs"

0 commit comments

Comments
 (0)