fix page zktrie: change the domain of nodeKey hashing to 512 instead of 256#282
Merged
dghelm merged 1 commit intoscroll-tech:developfrom Jun 27, 2024
Merged
Conversation
Am currently making a storage prover in noir and found this error In the zktrie repo nodekeys are hashed with ToSecureKey() in type/util.go (afaik) https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/util.go#L107 ToSecureKey() uses Hash() in types/bytes32.go which uses HASH_DOMAIN_BYTE32 as domain which is 256 *2 (512) see here: https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/hash.go#L16 and here is where i did my test in noir :D (account leaf is lower in same file) https://github.com/jimjimvalkema/scrollZkStorageProofs/blob/bcdd922405e046e99787b8b47f374befac170779/ScrollStorageProver/src/main.nr#L168
✅ Deploy Preview for scroll-documentation ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
dghelm
approved these changes
Jun 27, 2024
Contributor
dghelm
left a comment
There was a problem hiding this comment.
Great catch. Thanks for the close assessment here!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing issues
closes #281
Description
The docs states the domain used in creating the nodeKey is 256 but its actually 512.
In the zktrie repo nodekeys are hashed with ToSecureKey() in type/util.go.
ToSecureKey() uses Hash() in types/bytes32.go which uses HASH_DOMAIN_BYTE32 as domain which is 256 *2 (=512).
ToSecureKey: https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/util.go#L107
HASH_DOMAIN_BYTES32: https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/hash.go#L16
Am also making a storage prover and here is where i did my test in noir :D (account leaf is lower in same file).
https://github.com/jimjimvalkema/scrollZkStorageProofs/blob/bcdd922405e046e99787b8b47f374befac170779/ScrollStorageProver/src/main.nr#L168
...
Changes
Changed domain value for the nodeKey mentioned in account leaf and storage leaf section.
Changed the domain from 256 to 512