Skip to content

Commit

Permalink
README: add warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored May 29, 2017
1 parent dc3975f commit 2cb00a5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

A performance conscious library for merkle root and tree calculations.

**NOTE**: As is, this implementation is vulnerable to a forgery attack ([as a second pre-image attack](https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_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.

## Warnings
This implementation is vulnerable to a forgery attack ([as a second pre-image attack](https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_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)`.

This implementation is vulnerable to a forgery attack ([for an unbalanced merkle tree](https://bitcointalk.org/?topic=102395)), 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.


## Examples
Preamble
Expand Down

0 comments on commit 2cb00a5

Please sign in to comment.