xsleonard / go-merkle

A fixed Merkle Tree implementation in Go
MIT License
40 stars 15 forks source link

Generate a proof #15

Open AdamSLevy opened 5 years ago

AdamSLevy commented 5 years ago

Currently there is no convenient method for extracting only the branch required to prove a given node. It would be nice to be able to specify a height and a node index and be provided a Tree containing only the branch containing that node up to the root.

haseth commented 4 years ago

Hi @AdamSLevy,

If Input of height and index is given, then we can return an []Node from root to that indexed node.

We could verify and find the parent of the indexed node recursively and add it to slice height index. In that way we can return a []Node to user.

branchNodes[0] would be root node and branchNodes[h] would be the indexed node. branchNodes[1] would be either left/right child of branchNodes[0] depending on where indexed node is present.

We should be able to create a method for it.

pocockn commented 4 years ago

Hey @haseth did you ever get around to creating a convenience method for this? I'm looking to use this library in a project!

Thanks

haseth commented 4 years ago

Hey @haseth did you ever get around to creating a convenience method for this? I'm looking to use this library in a project!

Thanks

Hey @pocockn, I haven't worked on it as I didn't get an approval on it, I think.