arnaucube
arnaucube/miden-cryptoPublic Self-hosted repository
Merge branch 'main' into next
Bobbin Threadbare 43513081+bobbinth@users.noreply.github.com
Fri, 24 Jan 2025 17:34:50 -0800
commit

a424652ba77406578db4bbfce9953203811ef941

parent

0e853987328ccd7ef0efc1db91b3e9c59d9470ed

3 files changed, 22 insertions(+), 5 deletions(-)

jump to
M CHANGELOG.md → CHANGELOG.md

@@ -2,6 +2,11 @@ ## 0.14.0 (TBD)

- [BREAKING] Increment minimum supported Rust version to 1.84. +## 0.13.2 (2025-01-24) + +- Made `InnerNode` and `NodeMutation` public. Implemented (de)serialization of `LeafIndex` (#367). + + ## 0.13.1 (2024-12-26) - Generate reverse mutations set on applying of mutations set, implemented serialization of `MutationsSet` (#355).
M src/merkle/mod.rs → src/merkle/mod.rs

@@ -24,8 +24,8 @@ mod smt;

#[cfg(feature = "internal")] pub use smt::build_subtree_for_bench; pub use smt::{ - LeafIndex, MutationSet, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError, - SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH, + InnerNode, LeafIndex, MutationSet, NodeMutation, SimpleSmt, Smt, SmtLeaf, SmtLeafError, + SmtProof, SmtProofError, SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH, }; mod mmr;
M src/merkle/smt/mod.rs → src/merkle/smt/mod.rs

@@ -643,17 +643,29 @@ Self::new(node_index.value())

} } +impl<const DEPTH: u8> Serializable for LeafIndex<DEPTH> { + fn write_into<W: ByteWriter>(&self, target: &mut W) { + self.index.write_into(target); + } +} + +impl<const DEPTH: u8> Deserializable for LeafIndex<DEPTH> { + fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> { + Ok(Self { index: source.read()? }) + } +} + // MUTATIONS // ================================================================================================ -/// A change to an inner node of a [`SparseMerkleTree`] that hasn't yet been applied. +/// A change to an inner node of a sparse Merkle tree that hasn't yet been applied. /// [`MutationSet`] stores this type in relation to a [`NodeIndex`] to keep track of what changes /// need to occur at which node indices. #[derive(Debug, Clone, PartialEq, Eq)] pub enum NodeMutation { - /// Corresponds to [`SparseMerkleTree::remove_inner_node()`]. + /// Node needs to be removed. Removal, - /// Corresponds to [`SparseMerkleTree::insert_inner_node()`]. + /// Node needs to be inserted. Addition(InnerNode), }