Browse Source

feat: implement functionality needed for computing openings for recent blocks (#367)

* refactor: make `InnerNode` and `NodeMutation` public
* feat: implement serialization for `LeafIndex`
main v0.13.2
polydez 2 months ago
committed by GitHub
parent
commit
2a5b8ffb21
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 7 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -1
      Cargo.lock
  3. +1
    -1
      Cargo.toml
  4. +2
    -2
      src/merkle/mod.rs
  5. +15
    -3
      src/merkle/smt/mod.rs

+ 4
- 0
CHANGELOG.md

@ -1,3 +1,7 @@
## 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).

+ 1
- 1
Cargo.lock

@ -526,7 +526,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "miden-crypto"
version = "0.13.1"
version = "0.13.2"
dependencies = [
"assert_matches",
"blake3",

+ 1
- 1
Cargo.toml

@ -1,6 +1,6 @@
[package]
name = "miden-crypto"
version = "0.13.1"
version = "0.13.2"
description = "Miden Cryptographic primitives"
authors = ["miden contributors"]
readme = "README.md"

+ 2
- 2
src/merkle/mod.rs

@ -22,8 +22,8 @@ pub use path::{MerklePath, RootPath, ValuePath};
mod smt;
pub use smt::{
LeafIndex, MutationSet, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError,
SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
InnerNode, LeafIndex, MutationSet, NodeMutation, SimpleSmt, Smt, SmtLeaf, SmtLeafError,
SmtProof, SmtProofError, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
};
mod mmr;

+ 15
- 3
src/merkle/smt/mod.rs

@ -492,17 +492,29 @@ impl TryFrom for LeafIndex {
}
}
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),
}

Loading…
Cancel
Save