openvm_continuations/circuit/deferral/
mod.rs

1use openvm_circuit_primitives::{StructReflection, StructReflectionHelper};
2use openvm_recursion_circuit::prelude::DIGEST_SIZE;
3use openvm_recursion_circuit_derive::AlignedBorrow;
4pub use openvm_verify_stark_host::deferral::DeferralMerkleProofs;
5
6pub mod dummy;
7pub mod hook;
8pub mod inner;
9pub mod utils;
10
11pub const DEF_CIRCUIT_PVS_AIR_ID: usize = 0;
12
13pub const DEF_AGG_VERIFIER_AIR_ID: usize = 0;
14pub const DEF_AGG_PVS_AIR_ID: usize = 1;
15
16pub const DEF_HOOK_PVS_AIR_ID: usize = 0;
17
18// Used to domain-separate deferral Merkle leaves, which hash input_commit and
19// output_commit, from internal nodes, which hash two merkle_commit values.
20pub const DEF_LEAF_TAG: [u8; DIGEST_SIZE] = [1, 0, 0, 0, 0, 0, 0, 0];
21pub const DEF_INTERNAL_TAG: [u8; DIGEST_SIZE] = [2, 0, 0, 0, 0, 0, 0, 0];
22
23// Set to the default max trace log height of the deferral hook circuit
24const MAX_DEF_AGG_MERKLE_DEPTH: usize = 20;
25
26#[repr(C)]
27#[derive(AlignedBorrow, StructReflection, Clone, Copy)]
28pub struct DeferralCircuitPvs<F> {
29    /// Commit to the input to the deferral circuit
30    pub input_commit: [F; DIGEST_SIZE],
31    /// Commit to the output of the deferral circuit given the input
32    pub output_commit: [F; DIGEST_SIZE],
33    /// Deferral circuit index, must be constrained to a constant
34    pub def_idx: F,
35}
36
37#[repr(C)]
38#[derive(AlignedBorrow, StructReflection, Clone, Copy)]
39pub struct DeferralAggregationPvs<F> {
40    /// Compression of input_commit and output_commit at the leaf layer, and
41    /// the Merkle root of the aggregation subtree this proof is the root of
42    /// at internal layers
43    pub merkle_commit: [F; DIGEST_SIZE],
44    /// Number of present deferral circuit proofs that we've seen so far
45    pub num_def_circuit_proofs: F,
46    /// Current Merkle depth of this subtree, there are be 2^merkle_depth
47    /// leaves (including padding)
48    pub merkle_depth: F,
49    /// Deferral circuit index that this subtree belongs to
50    pub def_idx: F,
51}