pub fn merklize<I>(prefix: &str, data: I) -> (MerkleNode, u8)
where
    I: IntoIterator<Item = MerkleNode>,
    <I as IntoIterator>::IntoIter: ExactSizeIterator<Item = MerkleNode>,
{
    let mut tag_engine = sha256::Hash::engine();
    tag_engine.input(prefix.as_bytes());
    tag_engine.input(":merkle:".as_bytes());

    let iter = data.into_iter();
    let width = iter.len();

    // Tagging merkle tree root
    let (root, height) = merklize_inner(&tag_engine, iter, 0, false, None);
    tag_engine.input("root:height=".as_bytes());
    tag_engine.input(&height.to_string().into_bytes());
    tag_engine.input(":width=".as_bytes());
    tag_engine.input(&width.to_string().into_bytes());
    let tag_hash = sha256::Hash::hash(&sha256::Hash::from_engine(tag_engine));
    let mut engine = MerkleNode::engine();
    engine.input(&tag_hash[..]);
    engine.input(&tag_hash[..]);
    root.commit_encode(&mut engine);
    let tagged_root = MerkleNode::from_engine(engine);

    (tagged_root, height)
}
/// Merklization procedure that uses tagged hashes with depth commitments
/// according to [LNPBP-81] standard of client-side-validation merklization
///
/// [LNPBP-81]: https://github.com/LNP-BP/LNPBPs/blob/master/lnpbp-0081.md
Merklization procedure that uses tagged hashes with depth commitments
according to [LNPBP-81] standard of client-side-validation merklization


Merklization procedure that uses tagged hashes with depth commitments according to [ LNPBP - 81 ] standard of client - side - validation merklization
pub fn merklize<I>(prefix: &str, data: I) -> (MerkleNode, u8)
where
    I: IntoIterator<Item = MerkleNode>,
    <I as IntoIterator>::IntoIter: ExactSizeIterator<Item = MerkleNode>,
{
    let mut tag_engine = sha256::Hash::engine();
    tag_engine.input(prefix.as_bytes());
    tag_engine.input(":merkle:".as_bytes());
    let iter = data.into_iter();
    let width = iter.len();
    // Tagging merkle tree root
    let (root, height) = merklize_inner(&tag_engine, iter, 0, false, None);
    tag_engine.input("root:height=".as_bytes());
    tag_engine.input(&height.to_string().into_bytes());
    tag_engine.input(":width=".as_bytes());
    tag_engine.input(&width.to_string().into_bytes());
    let tag_hash = sha256::Hash::hash(&sha256::Hash::from_engine(tag_engine));
    let mut engine = MerkleNode::engine();
    engine.input(&tag_hash[..]);
    engine.input(&tag_hash[..]);
    root.commit_encode(&mut engine);
    let tagged_root = MerkleNode::from_engine(engine);
    (tagged_root, height)
}
pub fn merklize < I > ( prefix : & str , data : I ) -> ( MerkleNode , u8 ) where I : IntoIterator < Item = MerkleNode > , < I as IntoIterator > :: IntoIter : ExactSizeIterator < Item = MerkleNode > , { let mut tag_engine = sha256 :: Hash :: engine ( ) ; tag_engine . input ( prefix . as_bytes ( ) ) ; tag_engine . input ( " " . as_bytes ( ) ) ; let iter = data . into_iter ( ) ; let width = iter . len ( ) ; // Tagging merkle tree root let ( root , height ) = merklize_inner ( & tag_engine , iter , 0 , false , None ) ; tag_engine . input ( " " . as_bytes ( ) ) ; tag_engine . input ( & height . to_string ( ) . into_bytes ( ) ) ; tag_engine . input ( " " . as_bytes ( ) ) ; tag_engine . input ( & width . to_string ( ) . into_bytes ( ) ) ; let tag_hash = sha256 :: Hash :: hash ( & sha256 :: Hash :: from_engine ( tag_engine ) ) ; let mut engine = MerkleNode :: engine ( ) ; engine . input ( & tag_hash [ .. ] ) ; engine . input ( & tag_hash [ .. ] ) ; root . commit_encode ( & mut engine ) ; let tagged_root = MerkleNode :: from_engine ( engine ) ; ( tagged_root , height ) }
Merklization procedure that uses tagged hashes with depth commitments
according to [LNPBP-81] standard of client-side-validation merklization
Merklization procedure that uses tagged hashes with depth commitments according to [ LNPBP - 81 ] standard of client - side - validation merklization
prefix
&str
data
I
prefix
&str
data
I