-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add TrieProof library #5826
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
base: master
Are you sure you want to change the base?
Add TrieProof library #5826
Conversation
Co-authored-by: Hadrien Croubois <[email protected]>
Co-authored-by: Arr00 <[email protected]>
🦋 Changeset detectedLatest commit: fd7d2b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
function verify( | ||
bytes memory key, | ||
bytes memory value, | ||
bytes[] memory proof, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder that proofs are almost always provided via calldata, as such calldata should be used here for reduced gas costs.
function _nibbles(bytes memory value) private pure returns (bytes memory) { | ||
uint256 length = value.length; | ||
bytes memory nibbles_ = new bytes(length * 2); | ||
for (uint256 i = 0; i < length; i++) { | ||
(nibbles_[i * 2], nibbles_[i * 2 + 1]) = (value[i] & 0xf0, value[i] & 0x0f); | ||
} | ||
return nibbles_; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder, a much more efficient approached has been added to Solady.
EDIT: more context https://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
Follow up from #5680
PR Checklist
npx changeset add
)