cbergoon / merkletree

A Merkle Tree implementation written in Go.
MIT License
495 stars 125 forks source link

code typo #15

Closed progamer71 closed 5 years ago

progamer71 commented 5 years ago

There is a typo in line 127 of merkle_tree.go. https://github.com/cbergoon/merkletree/blob/master/merkle_tree.go#L127

code

if bytes.Equal(currentParent.Left.Hash, current.Hash) {

should be

if bytes.Equal(currentParent.Right.Hash, current.Hash) {

(sorry I cannot make a pull request)

cbergoon commented 5 years ago

Hi @progamer71

The idea of the merkle proof path is that the missing hashes of the nodes that are required to prove a leafs membership to the tree are provided as a result. Essentially providing the information required to verify the merkle root without having the entire tree. Given this intent, I think the current implementation is correct.

There is a good StackExchange answer explaining this concept: https://bitcoin.stackexchange.com/a/50680

Cam

progamer71 commented 5 years ago

sorry I just got it. your are correct.