pessimistic_proof_core/aggchain_data/
aggchain_proof.rs

1use agglayer_primitives::Digest;
2use serde::{Deserialize, Serialize};
3use unified_bridge::AggchainProofPublicValues;
4
5use crate::{
6    aggchain_data::Vkey,
7    proof::{ConstrainedValues, IMPORTED_BRIDGE_EXIT_COMMITMENT_VERSION},
8};
9
10#[derive(Clone, Debug, Serialize, Deserialize)]
11pub struct AggchainProof {
12    /// Chain-specific commitment forwarded by the PP.
13    pub aggchain_params: Digest,
14    /// Verifying key for the aggchain proof program.
15    pub aggchain_vkey: Vkey,
16}
17
18impl AggchainProof {
19    /// Verifies the next proof in the sp1 buffer.
20    pub fn verify_aggchain_proof(&self, constrained_values: &ConstrainedValues) {
21        let _aggchain_proof_public_values = AggchainProofPublicValues {
22            prev_local_exit_root: constrained_values.initial_state_commitment.exit_root.into(),
23            new_local_exit_root: constrained_values.final_state_commitment.exit_root.into(),
24            l1_info_root: constrained_values.l1_info_root,
25            origin_network: constrained_values.origin_network,
26            aggchain_params: self.aggchain_params,
27            commit_imported_bridge_exits: constrained_values
28                .commit_imported_bridge_exits
29                .commitment(IMPORTED_BRIDGE_EXIT_COMMITMENT_VERSION),
30        };
31
32        #[cfg(target_os = "zkvm")]
33        {
34            // Panic upon invalid proof.
35            sp1_zkvm::lib::verify::verify_sp1_proof(
36                &self.aggchain_vkey,
37                &_aggchain_proof_public_values.hash(),
38            );
39        }
40    }
41}