sp1_core_executor/
subproof.rs

1//! Types and methods for subproof verification inside the [`crate::Executor`].
2
3use sp1_stark::{
4    baby_bear_poseidon2::BabyBearPoseidon2, MachineVerificationError, SP1ReduceProof,
5    StarkVerifyingKey,
6};
7
8/// Verifier used in runtime when `sp1_zkvm::precompiles::verify::verify_sp1_proof` is called. This
9/// is then used to sanity check that the user passed in the correct proof; the actual constraints
10/// happen in the recursion layer.
11///
12/// This needs to be passed in rather than written directly since the actual implementation relies
13/// on crates in recursion that depend on sp1-core.
14pub trait SubproofVerifier: Sync + Send {
15    /// Verify a deferred proof.
16    fn verify_deferred_proof(
17        &self,
18        proof: &SP1ReduceProof<BabyBearPoseidon2>,
19        vk: &StarkVerifyingKey<BabyBearPoseidon2>,
20        vk_hash: [u32; 8],
21        committed_value_digest: [u32; 8],
22    ) -> Result<(), MachineVerificationError<BabyBearPoseidon2>>;
23}
24
25/// A dummy verifier which does nothing.
26pub struct NoOpSubproofVerifier;
27
28impl SubproofVerifier for NoOpSubproofVerifier {
29    fn verify_deferred_proof(
30        &self,
31        _proof: &SP1ReduceProof<BabyBearPoseidon2>,
32        _vk: &StarkVerifyingKey<BabyBearPoseidon2>,
33        _vk_hash: [u32; 8],
34        _committed_value_digest: [u32; 8],
35    ) -> Result<(), MachineVerificationError<BabyBearPoseidon2>> {
36        Ok(())
37    }
38}