Skip to content

Commit

Permalink
document and link to tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor O'Hara authored and Connor O'Hara committed Apr 23, 2024
1 parent d98a921 commit d5e7a6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ use simple_merkle::{
mod namespaced_hash;
pub use namespaced_hash::*;

mod tendermint_hash;
pub use tendermint_hash::*;

// pub mod db;
pub mod nmt_proof;
pub mod simple_merkle;
Expand Down
4 changes: 4 additions & 0 deletions src/tendermint_hash.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use sha2::{Sha256, Digest};

use crate::simple_merkle::tree::MerkleHash;

fn hash(bytes: &[u8]) -> [u8; 32] {
let mut hasher = Sha256::new();
hasher.update(bytes);
Expand All @@ -18,9 +20,11 @@ fn inner_hash(left: &[u8], right: &[u8]) -> [u8; 32] {
hash([INNER_PREFIX, left, right].concat().as_slice())
}

/// A sha256 hasher, compatible with [Tendermint merkle hash](https://github.com/informalsystems/tendermint-rs/blob/979456c9f33463944f97f7ea3900640e59f7ea6d/tendermint/src/merkle.rs)
pub struct TmSha2Hasher;

impl TmSha2Hasher {
/// Create a new instance of the hasher
pub fn new() -> Self {
TmSha2Hasher
}
Expand Down

0 comments on commit d5e7a6c

Please sign in to comment.