{"repo":"bitcoinjs/merkle-lib","free":true,"listed":false,"github":"https://github.com/bitcoinjs/merkle-lib","clone":"git clone https://github.com/bitcoinjs/merkle-lib.git","description":"A performance conscious library for merkle root and tree calculations.","language":"JavaScript","stars":32,"topics":["bitcoin","merkle-tree","merkle-root","merkle","hash","digest"],"license":"MIT","category":"blockchain-web3","readme_excerpt":"merkle-lib A performance conscious library for merkle root and tree calculations. Warnings This implementation is vulnerable to a forgery attack as a second pre-image attack, see these[\\[1\\]](https://crypto.stackexchange.com/questions/2106/what-is-the-purpose-of-using-different-hash-functions-for-the-leaves-and-interna)[\\[2\\]](https://crypto.stackexchange.com/questions/43430/what-is-the-reason-to-separate-domains-in-the-internal-hash-algorithm-of-a-merkl/44971#44971) crypto.stackexchange questions for an explanation. To avoid this vulnerability, you should pre-hash your leaves using a different hash function than the function provided such that H(x) != H'(x) . Additionally, this implementation is vulnerable to a forgery attack for an unbalanced merkle tree, wherein, in an unbalanced merkle tree, the last leaf node can be duplicated to create an artificial balanced tree, resulting in the same root hash. To avoid this vulnerability [in this implementation], do not accept unbalanced merkle trees in your application. Examples Preamble Tree Root only (equivalent to tree[tree.length - 1] ) Proof (with verify) Credits Thanks to Meni Rosenfield on bitcointalk for the math.","default_branch":null,"files":null,"tree":[],"storefront":"/r/bitcoinjs","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/bitcoinjs/merkle-lib/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}