Skip to content

Reorder arguments for multiProof functions#3447

Merged
Amxx merged 9 commits intoOpenZeppelin:masterfrom
frangio:merkle-multiproof-reorder
Jun 3, 2022
Merged

Reorder arguments for multiProof functions#3447
Amxx merged 9 commits intoOpenZeppelin:masterfrom
frangio:merkle-multiproof-reorder

Conversation

@frangio
Copy link
Contributor

@frangio frangio commented Jun 1, 2022

Resolves part of #3441.

Reorders arguments for consistency with simple proofs.

@frangio frangio added this to the 4.7 milestone Jun 1, 2022
@frangio frangio requested a review from Amxx June 1, 2022 21:28
@Amxx
Copy link
Collaborator

Amxx commented Jun 2, 2022

While I understand the logic here, I must say I'm not a fan of this new format.

In particular because it separates the proof and the proofFlag arguments. The thing is, in multiProofVerify, the proof array should possibly be called "proofSiblings", and it is useless without the "proofFlags" array.

Afaik, the idea for having the proof being the first argument of the single version was to be able to do:

using Merkle for bytes32[];
...
proof.verify(root, leaf)

IMO this was a bad design from the start. Rater then proving a property on the proof, using the root, I would rather prove a property on the tree itself (namely that it contains a leaf) using the proof as an argument.

So I would personally have preferred

  • root.verifyInclusion(leaf, proof)
  • leaf.rebuildRoot(proof)
  • root.verifyIncusion(leaves, proofSiblings, proofFlags) (overloaded)
  • leaves.rebuildRoot(proofSiblings, proofFlags) (overloaded)

@frangio
Copy link
Contributor Author

frangio commented Jun 2, 2022

Reordered to proof, proofFlags, root, leaves. I also edited the documentation.

…ppelin-contracts into merkle-multiproof-reorder
@Amxx Amxx merged commit 1134434 into OpenZeppelin:master Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants