You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bitcoin's merkle tree hashes odd nodes with themselves (or nodes without a right sibling, I should say), leading to the duplicate txid vulnerability (a duplicate txid placed after an odd leaf ends up creating the same root as the valid block's commitment).
Switching to the type of merkle tree described in RFC6962 would be preferrable (it simply propagates odd nodes up a level without hashing them). It also has some other benefits: i.e. the ability to prove a leaf vs. an internal node.
We could also require the leaves to be sorted for non-existence proofs.
RFC7574 is also an option. It looks like it pads the leaves with zero hashes until the amount of leaves reaches the nearest power of two (?). This is nicer than rfc6962 in that all the leaves are guaranteed to be the same depth. Might make dealing with proofs more sane.
Though, if we just wanted the leaves to be the same depth, we could do a combination of both. RFC6962-style, but if the leaves are odd, we pad them with a single zero-hash. This ensures that the odd leaf never gets propagated up. For all levels above the leaves, we propagate the odd hash up.
Activity
chjj commentedon Jun 8, 2018
RFC7574 is also an option. It looks like it pads the leaves with zero hashes until the amount of leaves reaches the nearest power of two (?). This is nicer than rfc6962 in that all the leaves are guaranteed to be the same depth. Might make dealing with proofs more sane.
Though, if we just wanted the leaves to be the same depth, we could do a combination of both. RFC6962-style, but if the leaves are odd, we pad them with a single zero-hash. This ensures that the odd leaf never gets propagated up. For all levels above the leaves, we propagate the odd hash up.
edit: See also, bittorrent's BEP 0030: http://bittorrent.org/beps/bep_0030.html
chjj commentedon Jun 8, 2018
Note that changing any of this will also require changing the bip37-style SPV (which we should remove in the future anyway).