From 0ca2ccc667f95ca381510c0dea9ecece0623bc6b Mon Sep 17 00:00:00 2001 From: Xinding Wei Date: Wed, 23 Apr 2025 16:12:38 -0700 Subject: [PATCH 1/3] Add e2e stark proof support --- crates/cli/src/commands/prove.rs | 40 +++++++++++- crates/sdk/src/codec.rs | 21 ++++++- crates/sdk/src/lib.rs | 19 ++++++ crates/sdk/src/prover/agg.rs | 103 +++++++++++++++++++++---------- crates/sdk/src/prover/stark.rs | 13 ++++ crates/sdk/src/types.rs | 8 +++ 6 files changed, 169 insertions(+), 35 deletions(-) diff --git a/crates/cli/src/commands/prove.rs b/crates/cli/src/commands/prove.rs index 2dbc07add8..09e2af889e 100644 --- a/crates/cli/src/commands/prove.rs +++ b/crates/cli/src/commands/prove.rs @@ -5,7 +5,7 @@ use eyre::Result; use openvm_sdk::{ commit::AppExecutionCommit, config::SdkVmConfig, - fs::{read_app_pk_from_file, read_exe_from_file, write_app_proof_to_file}, + fs::{encode_to_file, read_app_pk_from_file, read_exe_from_file, write_app_proof_to_file}, keygen::AppProvingKey, NonRootCommittedExe, Sdk, StdIn, }; @@ -42,6 +42,22 @@ enum ProveSubCommand { #[arg(long, action, help = "Path to output proof", default_value = DEFAULT_APP_PROOF_PATH)] output: PathBuf, }, + Stark { + #[arg(long, action, help = "Path to app proving key", default_value = DEFAULT_APP_PK_PATH)] + app_pk: PathBuf, + + #[arg(long, action, help = "Path to OpenVM executable", default_value = DEFAULT_APP_EXE_PATH)] + exe: PathBuf, + + #[arg(long, value_parser, help = "Input to OpenVM program")] + input: Option, + + #[arg(long, action, help = "Path to output proof", default_value = DEFAULT_APP_PROOF_PATH)] + output: PathBuf, + + #[command(flatten)] + agg_tree_config: AggregationTreeConfig, + }, #[cfg(feature = "evm-prove")] Evm { #[arg(long, action, help = "Path to app proving key", default_value = DEFAULT_APP_PK_PATH)] @@ -76,6 +92,28 @@ impl ProveCmd { let app_proof = sdk.generate_app_proof(app_pk, committed_exe, input)?; write_app_proof_to_file(app_proof, output)?; } + ProveSubCommand::Stark { + app_pk, + exe, + input, + output, + agg_tree_config, + } => { + let mut sdk = sdk; + sdk.set_agg_tree_config(*agg_tree_config); + let (app_pk, committed_exe, input) = + Self::prepare_execution(&sdk, app_pk, exe, input)?; + let agg_pk = read_agg_pk_from_file(DEFAULT_AGG_PK_PATH).map_err(|e| { + eyre::eyre!("Failed to read aggregation proving key: {}\nPlease run 'cargo openvm setup' first", e) + })?; + let stark_proof = sdk.generate_e2e_stark_proof( + app_pk, + committed_exe, + agg_pk.agg_stark_pk, + input, + )?; + encode_to_file(output, stark_proof)?; + } #[cfg(feature = "evm-prove")] ProveSubCommand::Evm { app_pk, diff --git a/crates/sdk/src/codec.rs b/crates/sdk/src/codec.rs index c66f254625..68b2ac5bd0 100644 --- a/crates/sdk/src/codec.rs +++ b/crates/sdk/src/codec.rs @@ -16,7 +16,8 @@ use openvm_stark_backend::{ }; use p3_fri::CommitPhaseProofStep; -use super::{F, SC}; // BabyBearPoseidon2Config +use super::{F, SC}; +use crate::types::E2eStarkProof; // BabyBearPoseidon2Config type Challenge = BinomialExtensionField; @@ -59,6 +60,13 @@ impl Encode for ContinuationVmProof { } } +impl Encode for E2eStarkProof { + fn encode(&self, writer: &mut W) -> Result<()> { + self.proof.encode(writer)?; + encode_slice(&self.user_public_values, writer) + } +} + impl Encode for UserPublicValuesProof { fn encode(&self, writer: &mut W) -> Result<()> { encode_slice(&self.proof, writer)?; @@ -323,6 +331,17 @@ impl Decode for ContinuationVmProof { } } +impl Decode for E2eStarkProof { + fn decode(reader: &mut R) -> Result { + let proof = Proof::decode(reader)?; + let user_public_values = decode_vec(reader)?; + Ok(Self { + proof, + user_public_values, + }) + } +} + impl Decode for UserPublicValuesProof { fn decode(reader: &mut R) -> Result { let proof = decode_vec(reader)?; diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index fee53f6709..db70804b77 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -58,6 +58,8 @@ pub mod prover; mod stdin; pub use stdin::*; +use crate::types::E2eStarkProof; + pub mod fs; pub mod types; @@ -268,6 +270,23 @@ impl> GenericSdk { Ok(proof) } + pub fn generate_e2e_stark_proof>( + &self, + app_pk: Arc>, + app_exe: Arc, + agg_stark_pk: AggStarkProvingKey, + inputs: StdIn, + ) -> Result + where + VC::Executor: Chip, + VC::Periphery: Chip, + { + let stark_prover = + StarkProver::::new(app_pk, app_exe, agg_stark_pk, self.agg_tree_config); + let proof = stark_prover.generate_e2e_stark_proof(inputs); + Ok(proof) + } + #[cfg(feature = "evm-prove")] pub fn generate_evm_proof>( &self, diff --git a/crates/sdk/src/prover/agg.rs b/crates/sdk/src/prover/agg.rs index 42f0d85d58..dbacb0cf27 100644 --- a/crates/sdk/src/prover/agg.rs +++ b/crates/sdk/src/prover/agg.rs @@ -17,6 +17,7 @@ use crate::{ vm::{local::VmLocalProver, SingleSegmentVmProver}, RootVerifierLocalProver, }, + types::E2eStarkProof, NonRootCommittedExe, RootSC, F, SC, }; @@ -83,50 +84,30 @@ impl> AggStarkProver { self.generate_root_proof_impl(root_verifier_input) } + pub fn generate_leaf_proofs(&self, app_proofs: &ContinuationVmProof) -> Vec> { + self.leaf_controller + .generate_proof(&self.leaf_prover, app_proofs) + } + pub fn generate_root_verifier_input( &self, app_proofs: ContinuationVmProof, ) -> RootVmVerifierInput { - let leaf_proofs = self - .leaf_controller - .generate_proof(&self.leaf_prover, &app_proofs); + let leaf_proofs = self.generate_leaf_proofs(&app_proofs); let public_values = app_proofs.user_public_values.public_values; - let internal_proof = self.generate_internal_proof_impl(leaf_proofs, &public_values); - RootVmVerifierInput { - proofs: vec![internal_proof], - public_values, - } + let e2e_stark_proof = self.generate_e2e_stark_proof(leaf_proofs, public_values); + self.wrap_e2e_stark_proof(e2e_stark_proof) } - fn generate_internal_proof_impl( + pub fn generate_e2e_stark_proof( &self, leaf_proofs: Vec>, - public_values: &[F], - ) -> Proof { + public_values: Vec, + ) -> E2eStarkProof { let mut internal_node_idx = -1; let mut internal_node_height = 0; let mut proofs = leaf_proofs; - let mut wrapper_layers = 0; - loop { - if proofs.len() == 1 { - let actual_air_heights = - self.root_prover - .execute_for_air_heights(RootVmVerifierInput { - proofs: vec![proofs[0].clone()], - public_values: public_values.to_vec(), - }); - // Root verifier can handle the internal proof. We can stop here. - if heights_le( - &actual_air_heights, - &self.root_prover.root_verifier_pk.air_heights, - ) { - break; - } - if wrapper_layers >= self.max_internal_wrapper_layers { - panic!("The heights of the root verifier still exceed the required heights after {} wrapper layers", self.max_internal_wrapper_layers); - } - wrapper_layers += 1; - } + while proofs.len() > 1 { let internal_inputs = InternalVmVerifierInput::chunk_leaf_or_internal_proofs( self.internal_prover .committed_exe @@ -158,7 +139,63 @@ impl> AggStarkProver { }); internal_node_height += 1; } - proofs.pop().unwrap() + E2eStarkProof { + proof: proofs.pop().unwrap(), + user_public_values: public_values, + } + } + + /// Wrap the e2e stark proof until its heights meet the requirements of the root verifier. + pub fn wrap_e2e_stark_proof(&self, e2e_stark_proof: E2eStarkProof) -> RootVmVerifierInput { + let internal_commit = self + .internal_prover + .committed_exe + .get_program_commit() + .into(); + let E2eStarkProof { + mut proof, + user_public_values, + } = e2e_stark_proof; + let mut wrapper_layers = 0; + loop { + let actual_air_heights = + self.root_prover + .execute_for_air_heights(RootVmVerifierInput { + proofs: vec![proof.clone()], + public_values: user_public_values.clone(), + }); + // Root verifier can handle the internal proof. We can stop here. + if heights_le( + &actual_air_heights, + &self.root_prover.root_verifier_pk.air_heights, + ) { + break; + } + if wrapper_layers >= self.max_internal_wrapper_layers { + panic!("The heights of the root verifier still exceed the required heights after {} wrapper layers", self.max_internal_wrapper_layers); + } + wrapper_layers += 1; + let input = InternalVmVerifierInput { + self_program_commit: internal_commit, + proofs: vec![proof.clone()], + }; + proof = info_span!( + "wrapper_layer", + group = format!("internal_wrapper.{wrapper_layers}") + ) + .in_scope(|| { + #[cfg(feature = "bench-metrics")] + { + metrics::counter!("fri.log_blowup") + .absolute(self.internal_prover.fri_params().log_blowup as u64); + } + SingleSegmentVmProver::prove(&self.internal_prover, input.write()) + }); + } + RootVmVerifierInput { + proofs: vec![proof], + public_values: user_public_values, + } } fn generate_root_proof_impl(&self, root_input: RootVmVerifierInput) -> Proof { diff --git a/crates/sdk/src/prover/stark.rs b/crates/sdk/src/prover/stark.rs index c95bdc0655..e6f1d4b481 100644 --- a/crates/sdk/src/prover/stark.rs +++ b/crates/sdk/src/prover/stark.rs @@ -9,6 +9,7 @@ use crate::{ config::AggregationTreeConfig, keygen::{AggStarkProvingKey, AppProvingKey}, prover::{agg::AggStarkProver, app::AppProver}, + types::E2eStarkProof, NonRootCommittedExe, RootSC, StdIn, F, SC, }; @@ -68,4 +69,16 @@ impl> StarkProver { let app_proof = self.app_prover.generate_app_proof(input); self.agg_prover.generate_root_verifier_input(app_proof) } + + pub fn generate_e2e_stark_proof(&self, input: StdIn) -> E2eStarkProof + where + VC: VmConfig, + VC::Executor: Chip, + VC::Periphery: Chip, + { + let app_proof = self.app_prover.generate_app_proof(input); + let leaf_proofs = self.agg_prover.generate_leaf_proofs(&app_proof); + self.agg_prover + .generate_e2e_stark_proof(leaf_proofs, app_proof.user_public_values.public_values) + } } diff --git a/crates/sdk/src/types.rs b/crates/sdk/src/types.rs index f305505bef..4dcb2489bd 100644 --- a/crates/sdk/src/types.rs +++ b/crates/sdk/src/types.rs @@ -1,7 +1,9 @@ use std::iter::{once, repeat}; use itertools::Itertools; +use openvm_continuations::{F, SC}; use openvm_native_recursion::halo2::{wrapper::EvmVerifierByteCode, Fr, RawEvmProof}; +use openvm_stark_backend::proof::Proof; use serde::{Deserialize, Serialize}; use serde_with::serde_as; use thiserror::Error; @@ -49,6 +51,12 @@ pub struct EvmProof { pub proof_data: ProofData, } +#[derive(Clone, Deserialize, Serialize)] +pub struct E2eStarkProof { + pub proof: Proof, + pub user_public_values: Vec, +} + #[derive(Debug, Error)] pub enum EvmProofConversionError { #[error("Invalid length of proof")] From 75b56c938083a4a02518187e1e74440f1e413a5e Mon Sep 17 00:00:00 2001 From: Xinding Wei Date: Wed, 23 Apr 2025 17:35:52 -0700 Subject: [PATCH 2/3] Expose wrap_e2e_stark_proof --- crates/cli/src/commands/prove.rs | 14 ++--- crates/sdk/src/prover/agg.rs | 104 ++++++++++++++++++------------- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/crates/cli/src/commands/prove.rs b/crates/cli/src/commands/prove.rs index 09e2af889e..ceb3e0932e 100644 --- a/crates/cli/src/commands/prove.rs +++ b/crates/cli/src/commands/prove.rs @@ -2,18 +2,18 @@ use std::{path::PathBuf, sync::Arc}; use clap::Parser; use eyre::Result; +#[cfg(feature = "evm-prove")] +use openvm_sdk::fs::write_evm_proof_to_file; use openvm_sdk::{ commit::AppExecutionCommit, - config::SdkVmConfig, - fs::{encode_to_file, read_app_pk_from_file, read_exe_from_file, write_app_proof_to_file}, + config::{AggregationTreeConfig, SdkVmConfig}, + fs::{ + encode_to_file, read_agg_pk_from_file, read_app_pk_from_file, read_exe_from_file, + write_app_proof_to_file, + }, keygen::AppProvingKey, NonRootCommittedExe, Sdk, StdIn, }; -#[cfg(feature = "evm-prove")] -use openvm_sdk::{ - config::AggregationTreeConfig, - fs::{read_agg_pk_from_file, write_evm_proof_to_file}, -}; use crate::{ default::*, diff --git a/crates/sdk/src/prover/agg.rs b/crates/sdk/src/prover/agg.rs index dbacb0cf27..d4f87f7a30 100644 --- a/crates/sdk/src/prover/agg.rs +++ b/crates/sdk/src/prover/agg.rs @@ -6,6 +6,7 @@ use openvm_continuations::verifier::{ root::types::RootVmVerifierInput, }; use openvm_native_circuit::NativeConfig; +use openvm_native_compiler::ir::DIGEST_SIZE; use openvm_native_recursion::hints::Hintable; use openvm_stark_sdk::{engine::StarkFriEngine, openvm_stark_backend::proof::Proof}; use tracing::info_span; @@ -152,50 +153,13 @@ impl> AggStarkProver { .committed_exe .get_program_commit() .into(); - let E2eStarkProof { - mut proof, - user_public_values, - } = e2e_stark_proof; - let mut wrapper_layers = 0; - loop { - let actual_air_heights = - self.root_prover - .execute_for_air_heights(RootVmVerifierInput { - proofs: vec![proof.clone()], - public_values: user_public_values.clone(), - }); - // Root verifier can handle the internal proof. We can stop here. - if heights_le( - &actual_air_heights, - &self.root_prover.root_verifier_pk.air_heights, - ) { - break; - } - if wrapper_layers >= self.max_internal_wrapper_layers { - panic!("The heights of the root verifier still exceed the required heights after {} wrapper layers", self.max_internal_wrapper_layers); - } - wrapper_layers += 1; - let input = InternalVmVerifierInput { - self_program_commit: internal_commit, - proofs: vec![proof.clone()], - }; - proof = info_span!( - "wrapper_layer", - group = format!("internal_wrapper.{wrapper_layers}") - ) - .in_scope(|| { - #[cfg(feature = "bench-metrics")] - { - metrics::counter!("fri.log_blowup") - .absolute(self.internal_prover.fri_params().log_blowup as u64); - } - SingleSegmentVmProver::prove(&self.internal_prover, input.write()) - }); - } - RootVmVerifierInput { - proofs: vec![proof], - public_values: user_public_values, - } + wrap_e2e_stark_proof( + &self.internal_prover, + &self.root_prover, + internal_commit, + self.max_internal_wrapper_layers, + e2e_stark_proof, + ) } fn generate_root_proof_impl(&self, root_input: RootVmVerifierInput) -> Proof { @@ -241,6 +205,58 @@ impl LeafProvingController { } } +/// Wrap the e2e stark proof until its heights meet the requirements of the root verifier. +pub fn wrap_e2e_stark_proof>( + internal_prover: &VmLocalProver, + root_prover: &RootVerifierLocalProver, + internal_commit: [F; DIGEST_SIZE], + max_internal_wrapper_layers: usize, + e2e_stark_proof: E2eStarkProof, +) -> RootVmVerifierInput { + let E2eStarkProof { + mut proof, + user_public_values, + } = e2e_stark_proof; + let mut wrapper_layers = 0; + loop { + let actual_air_heights = root_prover.execute_for_air_heights(RootVmVerifierInput { + proofs: vec![proof.clone()], + public_values: user_public_values.clone(), + }); + // Root verifier can handle the internal proof. We can stop here. + if heights_le( + &actual_air_heights, + &root_prover.root_verifier_pk.air_heights, + ) { + break; + } + if wrapper_layers >= max_internal_wrapper_layers { + panic!("The heights of the root verifier still exceed the required heights after {} wrapper layers", max_internal_wrapper_layers); + } + wrapper_layers += 1; + let input = InternalVmVerifierInput { + self_program_commit: internal_commit, + proofs: vec![proof.clone()], + }; + proof = info_span!( + "wrapper_layer", + group = format!("internal_wrapper.{wrapper_layers}") + ) + .in_scope(|| { + #[cfg(feature = "bench-metrics")] + { + metrics::counter!("fri.log_blowup") + .absolute(internal_prover.fri_params().log_blowup as u64); + } + SingleSegmentVmProver::prove(internal_prover, input.write()) + }); + } + RootVmVerifierInput { + proofs: vec![proof], + public_values: user_public_values, + } +} + fn heights_le(a: &[usize], b: &[usize]) -> bool { assert_eq!(a.len(), b.len()); a.iter().zip(b.iter()).all(|(a, b)| a <= b) From b6272951546ee6c2931f7a489822421163019960 Mon Sep 17 00:00:00 2001 From: Xinding Wei Date: Mon, 28 Apr 2025 16:50:27 -0700 Subject: [PATCH 3/3] Move E2eStarkProof to openvm-continuations crate --- .../src/verifier/internal/types.rs | 49 ++++++++++++------- crates/sdk/src/codec.rs | 9 ++-- crates/sdk/src/lib.rs | 8 +-- crates/sdk/src/prover/agg.rs | 13 +++-- crates/sdk/src/prover/stark.rs | 7 +-- crates/sdk/src/types.rs | 8 --- 6 files changed, 51 insertions(+), 43 deletions(-) diff --git a/crates/continuations/src/verifier/internal/types.rs b/crates/continuations/src/verifier/internal/types.rs index 9512518843..400100f9ae 100644 --- a/crates/continuations/src/verifier/internal/types.rs +++ b/crates/continuations/src/verifier/internal/types.rs @@ -30,6 +30,36 @@ pub struct InternalVmVerifierInput { } assert_impl_all!(InternalVmVerifierInput: Serialize, DeserializeOwned); +/// The final output of the internal VM verifier. +#[derive(Deserialize, Serialize, Derivative)] +#[serde(bound = "")] +#[derivative(Clone(bound = "Com: Clone"))] +pub struct E2eStarkProof { + pub proof: Proof, + pub user_public_values: Vec>, +} +assert_impl_all!(E2eStarkProof: Serialize, DeserializeOwned); + +/// Aggregated state of all segments +#[derive(Debug, Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct InternalVmVerifierPvs { + pub vm_verifier_pvs: VmVerifierPvs, + pub extra_pvs: InternalVmVerifierExtraPvs, +} + +/// Extra PVs for internal VM verifier except VmVerifierPvs. +#[derive(Debug, Clone, Copy, AlignedBorrow)] +#[repr(C)] +pub struct InternalVmVerifierExtraPvs { + /// The commitment of the leaf verifier program. + pub leaf_verifier_commit: [T; DIGEST_SIZE], + /// For recursion verification, a program need its own commitment, but its own commitment + /// cannot be hardcoded inside the program itself. So the commitment has to be read from + /// external and be committed. + pub internal_program_commit: [T; DIGEST_SIZE], +} + impl InternalVmVerifierInput { pub fn chunk_leaf_or_internal_proofs( self_program_commit: [Val; DIGEST_SIZE], @@ -45,13 +75,6 @@ impl InternalVmVerifierInput { .collect() } } -/// Aggregated state of all segments -#[derive(Debug, Clone, Copy, AlignedBorrow)] -#[repr(C)] -pub struct InternalVmVerifierPvs { - pub vm_verifier_pvs: VmVerifierPvs, - pub extra_pvs: InternalVmVerifierExtraPvs, -} impl InternalVmVerifierPvs> { pub fn uninit>(builder: &mut Builder) -> Self { @@ -70,18 +93,6 @@ impl InternalVmVerifierPvs> { } } -/// Extra PVs for internal VM verifier except VmVerifierPvs. -#[derive(Debug, Clone, Copy, AlignedBorrow)] -#[repr(C)] -pub struct InternalVmVerifierExtraPvs { - /// The commitment of the leaf verifier program. - pub leaf_verifier_commit: [T; DIGEST_SIZE], - /// For recursion verification, a program need its own commitment, but its own commitment - /// cannot be hardcoded inside the program itself. So the commitment has to be read from - /// external and be committed. - pub internal_program_commit: [T; DIGEST_SIZE], -} - impl InternalVmVerifierExtraPvs> { pub fn uninit>(builder: &mut Builder) -> Self { Self { diff --git a/crates/sdk/src/codec.rs b/crates/sdk/src/codec.rs index 68b2ac5bd0..5bfabddce9 100644 --- a/crates/sdk/src/codec.rs +++ b/crates/sdk/src/codec.rs @@ -3,7 +3,9 @@ use std::io::{self, Cursor, Read, Result, Write}; use openvm_circuit::{ arch::ContinuationVmProof, system::memory::tree::public_values::UserPublicValuesProof, }; -use openvm_continuations::verifier::root::types::RootVmVerifierInput; +use openvm_continuations::verifier::{ + internal::types::E2eStarkProof, root::types::RootVmVerifierInput, +}; use openvm_native_compiler::ir::DIGEST_SIZE; use openvm_native_recursion::hints::{InnerBatchOpening, InnerFriProof, InnerQueryProof}; use openvm_stark_backend::{ @@ -17,7 +19,6 @@ use openvm_stark_backend::{ use p3_fri::CommitPhaseProofStep; use super::{F, SC}; -use crate::types::E2eStarkProof; // BabyBearPoseidon2Config type Challenge = BinomialExtensionField; @@ -60,7 +61,7 @@ impl Encode for ContinuationVmProof { } } -impl Encode for E2eStarkProof { +impl Encode for E2eStarkProof { fn encode(&self, writer: &mut W) -> Result<()> { self.proof.encode(writer)?; encode_slice(&self.user_public_values, writer) @@ -331,7 +332,7 @@ impl Decode for ContinuationVmProof { } } -impl Decode for E2eStarkProof { +impl Decode for E2eStarkProof { fn decode(reader: &mut R) -> Result { let proof = Proof::decode(reader)?; let user_public_values = decode_vec(reader)?; diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index db70804b77..2f612c63d5 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -20,7 +20,9 @@ use openvm_circuit::{ program::trace::VmCommittedExe, }, }; -use openvm_continuations::verifier::root::types::RootVmVerifierInput; +use openvm_continuations::verifier::{ + internal::types::E2eStarkProof, root::types::RootVmVerifierInput, +}; pub use openvm_continuations::{ static_verifier::{DefaultStaticVerifierPvHandler, StaticVerifierPvHandler}, RootSC, C, F, SC, @@ -58,8 +60,6 @@ pub mod prover; mod stdin; pub use stdin::*; -use crate::types::E2eStarkProof; - pub mod fs; pub mod types; @@ -276,7 +276,7 @@ impl> GenericSdk { app_exe: Arc, agg_stark_pk: AggStarkProvingKey, inputs: StdIn, - ) -> Result + ) -> Result> where VC::Executor: Chip, VC::Periphery: Chip, diff --git a/crates/sdk/src/prover/agg.rs b/crates/sdk/src/prover/agg.rs index d4f87f7a30..5bdd3f8d5f 100644 --- a/crates/sdk/src/prover/agg.rs +++ b/crates/sdk/src/prover/agg.rs @@ -2,7 +2,8 @@ use std::sync::Arc; use openvm_circuit::arch::ContinuationVmProof; use openvm_continuations::verifier::{ - internal::types::InternalVmVerifierInput, leaf::types::LeafVmVerifierInput, + internal::types::{E2eStarkProof, InternalVmVerifierInput}, + leaf::types::LeafVmVerifierInput, root::types::RootVmVerifierInput, }; use openvm_native_circuit::NativeConfig; @@ -18,7 +19,6 @@ use crate::{ vm::{local::VmLocalProver, SingleSegmentVmProver}, RootVerifierLocalProver, }, - types::E2eStarkProof, NonRootCommittedExe, RootSC, F, SC, }; @@ -104,7 +104,7 @@ impl> AggStarkProver { &self, leaf_proofs: Vec>, public_values: Vec, - ) -> E2eStarkProof { + ) -> E2eStarkProof { let mut internal_node_idx = -1; let mut internal_node_height = 0; let mut proofs = leaf_proofs; @@ -147,7 +147,10 @@ impl> AggStarkProver { } /// Wrap the e2e stark proof until its heights meet the requirements of the root verifier. - pub fn wrap_e2e_stark_proof(&self, e2e_stark_proof: E2eStarkProof) -> RootVmVerifierInput { + pub fn wrap_e2e_stark_proof( + &self, + e2e_stark_proof: E2eStarkProof, + ) -> RootVmVerifierInput { let internal_commit = self .internal_prover .committed_exe @@ -211,7 +214,7 @@ pub fn wrap_e2e_stark_proof>( root_prover: &RootVerifierLocalProver, internal_commit: [F; DIGEST_SIZE], max_internal_wrapper_layers: usize, - e2e_stark_proof: E2eStarkProof, + e2e_stark_proof: E2eStarkProof, ) -> RootVmVerifierInput { let E2eStarkProof { mut proof, diff --git a/crates/sdk/src/prover/stark.rs b/crates/sdk/src/prover/stark.rs index e6f1d4b481..342fe68913 100644 --- a/crates/sdk/src/prover/stark.rs +++ b/crates/sdk/src/prover/stark.rs @@ -1,7 +1,9 @@ use std::sync::Arc; use openvm_circuit::arch::VmConfig; -use openvm_continuations::verifier::root::types::RootVmVerifierInput; +use openvm_continuations::verifier::{ + internal::types::E2eStarkProof, root::types::RootVmVerifierInput, +}; use openvm_stark_backend::{proof::Proof, Chip}; use openvm_stark_sdk::engine::StarkFriEngine; @@ -9,7 +11,6 @@ use crate::{ config::AggregationTreeConfig, keygen::{AggStarkProvingKey, AppProvingKey}, prover::{agg::AggStarkProver, app::AppProver}, - types::E2eStarkProof, NonRootCommittedExe, RootSC, StdIn, F, SC, }; @@ -70,7 +71,7 @@ impl> StarkProver { self.agg_prover.generate_root_verifier_input(app_proof) } - pub fn generate_e2e_stark_proof(&self, input: StdIn) -> E2eStarkProof + pub fn generate_e2e_stark_proof(&self, input: StdIn) -> E2eStarkProof where VC: VmConfig, VC::Executor: Chip, diff --git a/crates/sdk/src/types.rs b/crates/sdk/src/types.rs index 4dcb2489bd..f305505bef 100644 --- a/crates/sdk/src/types.rs +++ b/crates/sdk/src/types.rs @@ -1,9 +1,7 @@ use std::iter::{once, repeat}; use itertools::Itertools; -use openvm_continuations::{F, SC}; use openvm_native_recursion::halo2::{wrapper::EvmVerifierByteCode, Fr, RawEvmProof}; -use openvm_stark_backend::proof::Proof; use serde::{Deserialize, Serialize}; use serde_with::serde_as; use thiserror::Error; @@ -51,12 +49,6 @@ pub struct EvmProof { pub proof_data: ProofData, } -#[derive(Clone, Deserialize, Serialize)] -pub struct E2eStarkProof { - pub proof: Proof, - pub user_public_values: Vec, -} - #[derive(Debug, Error)] pub enum EvmProofConversionError { #[error("Invalid length of proof")]