openvm_sdk/verifier/root/
vars.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use openvm_native_compiler::prelude::*;
use openvm_native_recursion::{hints::Hintable, vars::StarkProofVariable};
use openvm_stark_sdk::openvm_stark_backend::{config::Val, prover::types::Proof};

use crate::{verifier::root::types::RootVmVerifierInput, C, SC};

#[derive(DslVariable, Clone)]
pub struct RootVmVerifierInputVariable<C: Config> {
    /// The proofs of leaf verifier or internal verifier in the execution order.
    pub proofs: Array<C, StarkProofVariable<C>>,
    /// Public values to expose
    pub public_values: Array<C, Felt<C::F>>,
}

impl Hintable<C> for RootVmVerifierInput<SC> {
    type HintVariable = RootVmVerifierInputVariable<C>;

    fn read(builder: &mut Builder<C>) -> Self::HintVariable {
        let proofs = Vec::<Proof<SC>>::read(builder);
        let public_values = Vec::<Val<SC>>::read(builder);
        Self::HintVariable {
            proofs,
            public_values,
        }
    }

    fn write(&self) -> Vec<Vec<<C as Config>::N>> {
        let mut stream = self.proofs.write();
        stream.extend(self.public_values.write());
        stream
    }
}