3 ms·
Please never ever ever implement a Merkle tree as you did in https://github.com/jbenet/random-ideas/issues/20 https://github.com/jbenet/random-ideas/issues/20 .
by KMag 12y ago
Please never ever ever implement a Merkle tree as you did in https://github.com/jbenet/random-ideas/issues/20 https://github.com/jbenet/random-ideas/issues/20 . This is vulnerable to the same trivial collision attack as the original Gnutella THEX proposal.
EDIT: also, please implement non-power-of-2 leaf node Merkle trees as power-of-2 lead node trees with the rightmost leaves containing the hashes of the zero length array, that way the final block along with its hash chain to the root provides a cryptographic proof of file length. This prevents denial-of-service mischief where a malicious server claims a given resource is terabytes large and a poorly written client starts allocating TB of disk space on a filesystem that doesn't support sparse files.
- KMag 12y agoOr, more efficiently, at each level of the tree where there are an odd number of nodes, add another leaf node containing the empty byte array on the right side of the tree to make an even number of nodes.