agglayer_types/aggchain_data/
aggchain_proof.rs

1use agglayer_interop_types::aggchain_proof::Proof;
2use agglayer_primitives::Digest;
3use pessimistic_proof::core;
4use sp1_sdk::SP1VerifyingKey;
5use unified_bridge::AggchainProofPublicValues;
6
7use crate::aggchain_data::PayloadWithCtx;
8
9/// Aggchain proof with aggchain params and optional public values for debug
10/// purposes.
11#[derive(Clone, Debug)]
12pub struct Payload {
13    /// STARK of the aggchain proof.
14    pub proof: Proof,
15    /// Chain-specific commitment forwarded through the PP.
16    pub aggchain_params: Digest,
17    /// Optional aggchain proof public values.
18    pub public_values: Option<Box<AggchainProofPublicValues>>,
19}
20
21impl Payload {
22    pub fn aggchain_vkey_from_proof(&self) -> SP1VerifyingKey {
23        let Proof::SP1Stark(sp1_reduce_proof) = &self.proof;
24        sp1_reduce_proof.vkey.clone()
25    }
26}
27
28/// Aggchain proof data from the L1 and enforced by the agglayer.
29#[derive(Clone, Debug)]
30pub struct Context {
31    pub aggchain_vkey: [u32; 8],
32}
33
34impl From<PayloadWithCtx<Payload, Context>> for core::AggchainProof {
35    fn from(val: PayloadWithCtx<Payload, Context>) -> Self {
36        let PayloadWithCtx(
37            Payload {
38                aggchain_params, ..
39            },
40            Context { aggchain_vkey },
41        ) = val;
42
43        core::AggchainProof {
44            aggchain_params,
45            aggchain_vkey,
46        }
47    }
48}