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

Process and verify merkle proofs (and multiproof) with custom hash function #4887

Merged

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Feb 8, 2024

Fixes #4886

The hasher should be view, but the existing versions are pure. This is resulved by

  • Keeping the existing versions (pure)
  • Add new (view) versions that use the a custom hasher
  • Both for memory and calldata
  • Both for simple proofs and multiproofs

This large amount of code duplication is handled through procedural generation


  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Feb 8, 2024

🦋 Changeset detected

Latest commit: b7d56bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Amxx Amxx marked this pull request as ready for review February 12, 2024 20:11
@ernestognw ernestognw mentioned this pull request Feb 16, 2024
4 tasks
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed some nits but the PR looks good imo. It may just need to be tested with custom hashing functions but that can't be done until we release the merkle tree library.

I'd be fine leaving an issue and merging, wdyt @Amxx? I see codecov was flagging a drop in coverage. Investigating both #4977 and this drop

@Amxx Amxx added this to the 5.1 milestone Jun 27, 2024
@Amxx Amxx force-pushed the feature/cryptography/merkle-proof-custom-hash branch from b85551a to 9c7ab66 Compare June 27, 2024 14:59
contracts/utils/structs/MerkleTree.sol Outdated Show resolved Hide resolved
contracts/utils/cryptography/MerkleProof.sol Outdated Show resolved Hide resolved
test/utils/cryptography/MerkleProof.test.js Outdated Show resolved Hide resolved
ernestognw
ernestognw previously approved these changes Jul 15, 2024
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left a TODO for when we release the Typescript library

Copy link

socket-security bot commented Jul 15, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@openzeppelin/merkle-tree@1.0.7 Transitive: network +28 2.39 MB

🚮 Removed packages: npm/@openzeppelin/merkle-tree@1.0.6

View full report↗︎

@Amxx Amxx requested a review from ernestognw July 15, 2024 13:28
@Toto0712 Toto0712 mentioned this pull request Jul 15, 2024
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the tests with the new Merkle Tree release.
LGTM

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.

Add a MerkleProof.verify function that support arbitrary internal hashes
2 participants