miden_objects/block/
nullifier_witness.rs

1use crate::crypto::merkle::SmtProof;
2use crate::utils::serde::{
3    ByteReader,
4    ByteWriter,
5    Deserializable,
6    DeserializationError,
7    Serializable,
8};
9
10// NULLIFIER WITNESS
11// ================================================================================================
12
13/// A proof that a certain nullifier is in the nullifier tree with the contained state.
14#[derive(Debug, Clone)]
15pub struct NullifierWitness {
16    proof: SmtProof,
17}
18
19impl NullifierWitness {
20    /// Creates a new [`NullifierWitness`] from the given proof.
21    pub fn new(proof: SmtProof) -> Self {
22        Self { proof }
23    }
24
25    /// Returns a reference to the underlying [`SmtProof`].
26    pub fn proof(&self) -> &SmtProof {
27        &self.proof
28    }
29
30    /// Consumes the witness and returns the underlying [`SmtProof`].
31    pub fn into_proof(self) -> SmtProof {
32        self.proof
33    }
34}
35
36impl Serializable for NullifierWitness {
37    fn write_into<W: ByteWriter>(&self, target: &mut W) {
38        target.write(&self.proof);
39    }
40}
41
42impl Deserializable for NullifierWitness {
43    fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
44        let proof = source.read()?;
45        Ok(Self::new(proof))
46    }
47}