miden_objects/block/
account_witness.rs

1use crate::{Digest, crypto::merkle::MerklePath};
2
3// ACCOUNT WITNESS
4// ================================================================================================
5
6/// A proof that a certain account is in the account tree and whose current state is the contained
7/// initial state commitment.
8#[derive(Debug, Clone)]
9pub struct AccountWitness {
10    initial_state_commitment: Digest,
11    proof: MerklePath,
12}
13
14impl AccountWitness {
15    /// Constructs a new [`AccountWitness`] from the provided parts.
16    pub fn new(initial_state_commitment: Digest, proof: MerklePath) -> Self {
17        Self { initial_state_commitment, proof }
18    }
19
20    /// Returns the initial state commitment that this witness proves is the current state.
21    pub fn initial_state_commitment(&self) -> Digest {
22        self.initial_state_commitment
23    }
24
25    /// Returns the merkle path for the account tree of this witness.
26    pub fn proof(&self) -> &MerklePath {
27        &self.proof
28    }
29
30    /// Consumes self and returns the parts of the witness.
31    pub fn into_parts(self) -> (Digest, MerklePath) {
32        (self.initial_state_commitment, self.proof)
33    }
34}