Tree corruption when leaves have identical hashes #3
Labels
bug
Something isn't working
merkle-h0
Merkle tree implementing the H(0 | 0) = 0 optimization.
merkle-naive
Naive merkle tree implementation
merkle-single-leaf
Merkle tree implementing basic optimization for single non-zero leaf subtrees.
In
SMTHashZero
,SMTNaive
andSMTSingleLeaf
the leaf hash is simply computed asHash(value)
, wherevalue
is directly provided on callingaddLeaf
. This can easily lead to leaves and subtrees to have identical hashes.In these cases different trees branches will end up sharing common nodes.
Editing one such "repeated" leaf can corrupt the SMT as the shared nodes are deleted on replacing.
The same problem is not present in
SMTSingleLeafEx
whose hashes leaves asHash(index | value | 1)
.The text was updated successfully, but these errors were encountered: