-
Notifications
You must be signed in to change notification settings - Fork 184
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: squashing transient note hashes and nullifiers #6059
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1bd3b38
Add nullifier counter to note hash context.
LeilaWang fddd10f
Check given nullifier counters.
LeilaWang e48b154
Update logic for linking note hashes and nullifiers.
LeilaWang 8c35752
Rename SideEffectLinkedToNoteHash to Nullifier.
LeilaWang feebf60
Build hints and outputs in ts.
LeilaWang 9621efd
Renaming and tests.
LeilaWang c04a903
Merge remote-tracking branch 'origin/master' into lw/squash_transient…
LeilaWang 8553e2c
Update tests and snapshots.
LeilaWang 11eebd1
Merge remote-tracking branch 'origin/master' into lw/squash_transient…
LeilaWang 81502c3
Refactor private kernel public inputs composer.
LeilaWang f076971
Merge remote-tracking branch 'origin/master' into lw/squash_transient…
LeilaWang 6627ebd
Fix typo.
LeilaWang 5529f14
Merge remote-tracking branch 'origin/master' into lw/squash_transient…
LeilaWang 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 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 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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,14 @@ use dep::types::{ | |
max_block_number::MaxBlockNumber, membership_witness::NoteHashReadRequestMembershipWitness, | ||
private_circuit_public_inputs::PrivateCircuitPublicInputs, | ||
private_kernel::private_call_data::PrivateCallData, kernel_data::PrivateKernelData, | ||
side_effect::{SideEffect, SideEffectLinkedToNoteHash} | ||
nullifier::Nullifier, side_effect::SideEffect | ||
}, | ||
address::{AztecAddress, EthAddress, PartialAddress, compute_initialization_hash}, | ||
contract_class_id::ContractClassId, | ||
constants::{ | ||
MAX_NEW_NULLIFIERS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NOTE_HASHES_PER_CALL, | ||
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, | ||
MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL | ||
MAX_NEW_NULLIFIERS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, | ||
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, | ||
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL | ||
}, | ||
hash::{ | ||
compute_l2_to_l1_hash, pedersen_hash, private_functions_root_from_siblings, silo_note_hash, | ||
|
@@ -83,37 +83,6 @@ pub fn validate_note_hash_read_requests( | |
} | ||
} | ||
|
||
pub fn initialize_end_values( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
previous_kernel: PrivateKernelData, | ||
public_inputs: &mut PrivateKernelCircuitPublicInputsBuilder | ||
) { | ||
public_inputs.constants = previous_kernel.public_inputs.constants; | ||
public_inputs.min_revertible_side_effect_counter = previous_kernel.public_inputs.min_revertible_side_effect_counter; | ||
|
||
let start = previous_kernel.public_inputs.validation_requests; | ||
public_inputs.validation_requests.max_block_number = start.for_rollup.max_block_number; | ||
public_inputs.validation_requests.note_hash_read_requests = array_to_bounded_vec(start.note_hash_read_requests); | ||
public_inputs.validation_requests.nullifier_read_requests = array_to_bounded_vec(start.nullifier_read_requests); | ||
public_inputs.validation_requests.nullifier_key_validation_requests = array_to_bounded_vec(start.nullifier_key_validation_requests); | ||
|
||
// Ensure the arrays are the same as previously, before we start pushing more data onto them in other | ||
// functions within this circuit: | ||
let start = previous_kernel.public_inputs.end; | ||
|
||
public_inputs.end.new_note_hashes = array_to_bounded_vec(start.new_note_hashes); | ||
public_inputs.end.new_nullifiers = array_to_bounded_vec(start.new_nullifiers); | ||
|
||
public_inputs.end.private_call_stack = array_to_bounded_vec(start.private_call_stack); | ||
public_inputs.end.public_call_stack = array_to_bounded_vec(start.public_call_stack); | ||
public_inputs.end.new_l2_to_l1_msgs = array_to_bounded_vec(start.new_l2_to_l1_msgs); | ||
|
||
public_inputs.end.encrypted_logs_hashes = array_to_bounded_vec(start.encrypted_logs_hashes); | ||
public_inputs.end.unencrypted_logs_hashes = array_to_bounded_vec(start.unencrypted_logs_hashes); | ||
|
||
public_inputs.end.encrypted_log_preimages_length = start.encrypted_log_preimages_length; | ||
public_inputs.end.unencrypted_log_preimages_length = start.unencrypted_log_preimages_length; | ||
} | ||
|
||
fn perform_static_call_checks(private_call: PrivateCallData) { | ||
let public_inputs = private_call.call_stack_item.public_inputs; | ||
let is_static_call = public_inputs.call_context.is_static_call; | ||
|
@@ -217,11 +186,9 @@ pub fn update_end_values( | |
} | ||
} | ||
|
||
// Enhance commitments and nullifiers with domain separation whereby domain is the contract. | ||
// | ||
// nullifiers | ||
// Nullifiers | ||
let new_nullifiers = private_call_public_inputs.new_nullifiers; | ||
let mut siloed_new_nullifiers: BoundedVec<SideEffectLinkedToNoteHash, MAX_NEW_NULLIFIERS_PER_CALL> = BoundedVec::new(); | ||
let mut siloed_new_nullifiers: BoundedVec<Nullifier, MAX_NEW_NULLIFIERS_PER_CALL> = BoundedVec::new(); | ||
for i in 0..MAX_NEW_NULLIFIERS_PER_CALL { | ||
let new_nullifier = new_nullifiers[i]; | ||
if new_nullifier.value != 0 { | ||
|
@@ -231,7 +198,7 @@ pub fn update_end_values( | |
silo_note_hash(storage_contract_address, new_nullifier.note_hash) | ||
}; | ||
siloed_new_nullifiers.push( | ||
SideEffectLinkedToNoteHash { | ||
Nullifier { | ||
value: silo_nullifier(storage_contract_address, new_nullifier.value), | ||
counter: new_nullifier.counter, | ||
note_hash: siloed_note_hash | ||
|
@@ -241,19 +208,6 @@ pub fn update_end_values( | |
} | ||
public_inputs.end.new_nullifiers.extend_from_bounded_vec(siloed_new_nullifiers); | ||
|
||
// note hashes | ||
let new_note_hashes = private_call_public_inputs.new_note_hashes; | ||
let mut siloed_new_note_hashes: BoundedVec<SideEffect, MAX_NEW_NOTE_HASHES_PER_CALL> = BoundedVec::new(); | ||
for i in 0..MAX_NEW_NOTE_HASHES_PER_CALL { | ||
let new_note_hash = new_note_hashes[i].value; | ||
if new_note_hash != 0 { | ||
siloed_new_note_hashes.push( | ||
SideEffect { value: silo_note_hash(storage_contract_address, new_note_hash), counter: new_note_hashes[i].counter } | ||
); | ||
} | ||
} | ||
public_inputs.end.new_note_hashes.extend_from_bounded_vec(siloed_new_note_hashes); | ||
|
||
// Call stacks | ||
// Private call stack. | ||
let private_call_stack = array_to_bounded_vec(private_call.private_call_stack); | ||
|
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.
Creating specific structs for note hashes and nullifiers. Logs are still using SideEffect because Miranda is working on logs so I don't want to change it to create more conflicts.