-
Notifications
You must be signed in to change notification settings - Fork 284
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
feat: use truncated sha256 hashes in protocol circuits (wip) #3839
Closed
dan-aztec
wants to merge
38
commits into
master
from
dan/truncate-sha-256-instead-of-splitting-into-two-fr-fields
Closed
feat: use truncated sha256 hashes in protocol circuits (wip) #3839
dan-aztec
wants to merge
38
commits into
master
from
dan/truncate-sha-256-instead-of-splitting-into-two-fr-fields
+543
−774
Conversation
This file contains 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
dan-aztec
changed the title
feat: truncate hashes to field in protocol circuits
feat: truncate hashes to field in protocol circuits (wip)
Jan 4, 2024
Changes to circuit sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
Loading status checks…
… dan/truncate-sha-256-instead-of-splitting-into-two-fr-fields
dan-aztec
changed the title
feat: truncate hashes to field in protocol circuits (wip)
feat: use modulus remainder of hashes protocol circuits (wip)
Jan 5, 2024
Loading status checks…
…into-two-fr-fields
dan-aztec
commented
Jan 6, 2024
@@ -326,8 +323,12 @@ describe('sequencer/solo_block_builder', () => { | |||
|
|||
processedTx.data.end.newL2ToL1Msgs = makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x300); | |||
processedTx.data.end.newContracts = [makeNewContractData(seed + 0x1000)]; | |||
processedTx.data.end.encryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.encryptedLogs)); | |||
processedTx.data.end.unencryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.unencryptedLogs)); | |||
processedTx.data.end.encryptedLogsHash = Fr.fromBufferReduce( |
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.
fromBufferReduce
also does the modulus remainder style reduction to the prime field
Loading status checks…
…into-two-fr-fields
Loading status checks…
dan-aztec
changed the title
feat: use modulus remainder of hashes protocol circuits (wip)
feat: use modulus remainder of hashes in protocol circuits (wip)
Jan 6, 2024
Loading status checks…
Loading status checks…
…into-two-fr-fields
Loading status checks…
…ields' of https://github.com/AztecProtocol/aztec-packages into dan/truncate-sha-256-instead-of-splitting-into-two-fr-fields
dan-aztec
changed the title
feat: use modulus remainder of hashes in protocol circuits (wip)
feat: use truncated sha256 hashes in protocol circuits (wip)
Jan 8, 2024
Loading status checks…
…into-two-fr-fields
ludamad
deleted the
dan/truncate-sha-256-instead-of-splitting-into-two-fr-fields
branch
August 22, 2024 15:19
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.
confirmed by cryptography research that this is OK to do!
Reduces the hash values to a single Field (previously used 2 254-bit Field elements, as U128s, to maintain the the full 256 bit value).
Applies to:
Encrypted Logs Hash
Unencrypted Logs Hash
L1 to L2 Messages Hash
CallDataHash
in Noir, uses
hash::sha256_truncate_to_field
and which was added to typescript asSha256TruncateToField
. this is in contrast to doing division by the field modulus to reduce to a single field value, whichFr.FromBufferReduce
does.This reduces our security from 128 bits to 126 bits, which should still be enough.
This also requires changes on
Decoder.sol
to mirror the logic - switch the nestedsha256
of logs to usesha256ToField
, however this does the prime modulus reduction, instead of the "2 128bit numbers" approach of Noir/TS.