Skip to content

Commit

Permalink
file separators
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jan 10, 2024
1 parent 2f7263b commit c29d722
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/merkle/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use crate::{

use super::{MerkleError, MerklePath, NodeIndex};

// SPARSE MERKLE TREE
// ================================================================================================

/// An abstract description of a sparse Merkle tree.
///
/// A sparse Merkle tree is a key-value map which also supports proving that a given value is indeed
Expand Down Expand Up @@ -129,6 +132,25 @@ pub trait SparseMerkleTree<const DEPTH: u8> {
fn hash_value(value: Self::Value) -> RpoDigest;
}

// INNER NODE
// ================================================================================================

#[derive(Debug, Default, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct InnerNode {
left: RpoDigest,
right: RpoDigest,
}

impl InnerNode {
pub fn hash(&self) -> RpoDigest {
Rpo256::merge(&[self.left, self.right])
}
}

// LEAF INDEX
// ================================================================================================

/// The index of a leaf, at a depth known at compile-time.
pub struct LeafIndex<const DEPTH: u8> {
index: NodeIndex,
Expand Down Expand Up @@ -163,16 +185,3 @@ impl From<Word> for LeafIndex<64> {
Self::new_max_depth(value[0].inner())
}
}

#[derive(Debug, Default, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct InnerNode {
left: RpoDigest,
right: RpoDigest,
}

impl InnerNode {
pub fn hash(&self) -> RpoDigest {
Rpo256::merge(&[self.left, self.right])
}
}

0 comments on commit c29d722

Please sign in to comment.