diff --git a/src/lib.rs b/src/lib.rs index 052ace6..bde298a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/tendermint_hash.rs b/src/tendermint_hash.rs index 6a6a08e..fec4f53 100644 --- a/src/tendermint_hash.rs +++ b/src/tendermint_hash.rs @@ -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); @@ -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 }