-
Notifications
You must be signed in to change notification settings - Fork 598
feat: truncate SHA hashes inside circuits #5160
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
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
1d45d21
feat: init SHA truncation
MirandaWood 3ebc11c
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood bbe2e15
chore: update fixtures and fix merge issues
MirandaWood fb1664b
chore: clean comments and add docs,tests
MirandaWood a6f853c
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 2971a0d
fix: small merge fix + update new snap
MirandaWood b4688c4
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 672c7f9
chore: update fixtures and slither file
MirandaWood 4be5f22
chore: re run yarn fmt
MirandaWood 0cf4688
chore: re re run fmt
MirandaWood e47937b
fix: update sha in e2e tests + remove undef variable
MirandaWood e6473fe
chore: further comments + update sha on untested fns
MirandaWood 26ee73d
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood fffff8d
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood d6db80a
chore: update snaps and reimpl some truncation
MirandaWood 9828211
Merge remote-tracking branch 'origin/master' into mw/truncate-sha
MirandaWood 8b2a573
feat: integrate shatofield with parity circuits, update sol byte casting
MirandaWood 2b0da18
chore: fmt and slither
MirandaWood 645bab1
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 6d37df8
chore: fix merge changes, remove old contracts, add todos
MirandaWood f4dc0b6
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood ddae1b2
chore: fmt and slither
MirandaWood b0347be
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 97d8711
chore: fix outbox merge, fixtures, fmt
MirandaWood 21bd4f0
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood e993a71
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 2592549
chore: slither file
MirandaWood 7c55b2b
feat: address comments
MirandaWood 19869e9
chore: update fixtures
MirandaWood 333a1a4
feat: revert 31 byte trunc, pad to 32 everywhere
MirandaWood bfab245
chore: revert byte decoding
MirandaWood f2a47ed
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 9f3440f
chore: fmt, slither, update fixtures
MirandaWood e88ce82
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 7deceac
chore: update snaps, remove unused fns, comments
MirandaWood 94c4153
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 4005c7e
Merge branch 'master' into mw/truncate-sha
MirandaWood ac8d7d8
fix: pad in oubox test and msg hash
MirandaWood 7f421db
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 9275df3
chore: cleanup + rearrange truncation for logs
MirandaWood 172c5fb
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 781afa7
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 40879d9
chore: update fixtures and slither
MirandaWood 00c6582
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 6957874
feat: integrate truncated sha into new outbox
MirandaWood ded9066
Merge remote-tracking branch 'origin' into mw/truncate-sha
MirandaWood 724cf32
fix: outbox sha ts merge fixes
MirandaWood 3664afc
Merge branch 'master' into mw/truncate-sha
MirandaWood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
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.
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.
In integrating the truncated SHA into this PR, I discovered a discrepancy in byte casting between Solidity and Noir/ts.
e.g. say normal sha256 gives a result of
0x2e7ff14389eef3dc51597529149e01b49cb33829f7089438c8c145c8f352c17b.In Solidity the cleanest way it seems to drop a byte is
bytes31(thing). Turning it back into abytes32for checks and structs gives:0x2e7ff14389eef3dc51597529149e01b49cb33829f7089438c8c145c8f352c100.However, both
toBuffer()in ts andto_be_bytes()in Noir would give:0x002e7ff14389eef3dc51597529149e01b49cb33829f7089438c8c145c8f352c1The solidity version fails in-field checks since it still fills the most significant bytes, so I went for the Noir/TS version wherever checks are needed. That's why in some places
sha256ToField32is used, and in otherssha256ToField(which returnsbytes31).I also changed logs hashes to be treated as
bytes31wherever possible to avoid any issues with casting. The above fixes are a bit janky so I'm happy for any feedback on them.