Skip to main content

miden_core/deferred/
claim.rs

1use super::DeferredRoot;
2use crate::{
3    Word,
4    serde::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
5};
6
7/// The exact deferred-state claim proved by a precompile VM proof.
8///
9/// The root is the PVM STARK public input. The commitment identifies the claim in proof-request
10/// keys and downstream statements. For this claim type, the protocol defines that commitment to
11/// be the root itself.
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct DeferredClaim(DeferredRoot);
14
15impl DeferredClaim {
16    /// Creates a claim for `deferred_root`.
17    pub const fn new(deferred_root: DeferredRoot) -> Self {
18        Self(deferred_root)
19    }
20
21    /// Returns the deferred root used as the PVM STARK public input.
22    pub const fn root(self) -> DeferredRoot {
23        self.0
24    }
25
26    /// Returns the identifier used to bind and address proofs of this claim.
27    ///
28    /// For this claim type, the protocol defines the commitment as the root itself, so this
29    /// returns the same word as [`Self::root`].
30    pub const fn commitment(self) -> Word {
31        self.0
32    }
33}
34
35impl Serializable for DeferredClaim {
36    fn write_into<W: ByteWriter>(&self, target: &mut W) {
37        self.0.write_into(target);
38    }
39}
40
41impl Deserializable for DeferredClaim {
42    fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
43        Ok(Self::new(DeferredRoot::read_from(source)?))
44    }
45
46    fn min_serialized_size() -> usize {
47        DeferredRoot::min_serialized_size()
48    }
49}