Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions crates/miden-protocol/src/account/storage/map/witness.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use alloc::collections::BTreeMap;

use miden_core::utils::{
ByteReader,
ByteWriter,
Deserializable,
DeserializationError,
Serializable,
};
use miden_crypto::merkle::InnerNodeInfo;
use miden_crypto::merkle::smt::SmtProof;

Expand Down Expand Up @@ -110,6 +117,21 @@ impl From<StorageMapWitness> for SmtProof {
}
}

impl Serializable for StorageMapWitness {
fn write_into<W: ByteWriter>(&self, target: &mut W) {
self.proof.write_into(target);
self.entries.write_into(target);
}
}

impl Deserializable for StorageMapWitness {
fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
let proof = SmtProof::read_from(source)?;
let entries = BTreeMap::<Word, Word>::read_from(source)?;
Ok(Self { proof, entries })
}
}

#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
Expand Down
Loading