Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In some cases, getMultiProof can't get right answer #63

Open
CryptoRbtree opened this issue Sep 4, 2022 · 5 comments
Open

In some cases, getMultiProof can't get right answer #63

CryptoRbtree opened this issue Sep 4, 2022 · 5 comments
Labels

Comments

@CryptoRbtree
Copy link

const leaves = ['a', 'b', 'c'].map(x => SHA256(x))
const tree = new MerkleTree(leaves, SHA256)
const root = tree.getRoot().toString('hex')

const proofIndices = [0, 2]
const proofLeaves = proofIndices.map(i => leaves[i])
const multiProof = tree.getMultiProof(proofIndices)
console.log(multiProof)
console.log(tree.verifyMultiProof(root, proofIndices, proofLeaves, leaves.length, multiProof))
@Fraccaman
Copy link

I'm having the same problem

@tsudmi
Copy link

tsudmi commented Oct 10, 2022

There is a relevant discussion around that issue in OpenZeppelin/openzeppelin-contracts#3743

@frangio
Copy link
Contributor

frangio commented Oct 16, 2022

Working on this.

@frangio
Copy link
Contributor

frangio commented Oct 26, 2022

#68 will help but not fix this... The complete: true option introduced in that PR should be used for multiproofs. But it does not fix this snippet shared in this issue. We will be releasing a new merkle tree library that can properly generate all multiproofs.

Curious, is the use of SHA256 instead of Keccak256 significant?

@frangio
Copy link
Contributor

frangio commented Nov 1, 2022

We've released a new library that correctly generates multiproofs.

https://github.com/OpenZeppelin/merkle-tree

@miguelmota miguelmota added the bug label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants