github.com/Team-Kujira/tendermint@v0.34.24-indexer/crypto/merkle/doc.go (about)

     1  /*
     2  Package merkle computes a deterministic minimal height Merkle tree hash.
     3  If the number of items is not a power of two, some leaves
     4  will be at different levels. Tries to keep both sides of
     5  the tree the same size, but the left may be one greater.
     6  
     7  Use this for short deterministic trees, such as the validator list.
     8  For larger datasets, use IAVLTree.
     9  
    10  Be aware that the current implementation by itself does not prevent
    11  second pre-image attacks. Hence, use this library with caution.
    12  Otherwise you might run into similar issues as, e.g., in early Bitcoin:
    13  https://bitcointalk.org/?topic=102395
    14  
    15  	              *
    16  	             / \
    17  	           /     \
    18  	         /         \
    19  	       /             \
    20  	      *               *
    21  	     / \             / \
    22  	    /   \           /   \
    23  	   /     \         /     \
    24  	  *       *       *       h6
    25  	 / \     / \     / \
    26  	h0  h1  h2  h3  h4  h5
    27  
    28  TODO(ismail): add 2nd pre-image protection or clarify further on how we use this and why this secure.
    29  */
    30  package merkle