Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2aa7ed2
Verify built output for private init.
LeilaWang May 23, 2024
4bf7ad5
Tests for private kernel circuit public inputs composer.
LeilaWang May 24, 2024
cfb64c1
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 24, 2024
90681c8
Fixes after merge.
LeilaWang May 24, 2024
5a5bbd8
Update tests.
LeilaWang May 24, 2024
e07cef8
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 24, 2024
92c792f
Move tests to folder.
LeilaWang May 24, 2024
5354e92
Merge branch 'master' into lw/circuit_output_validation
ludamad May 24, 2024
85f68c3
Use fixture builder for private call.
LeilaWang May 26, 2024
2774eb2
Merge remote-tracking branch 'origin/lw/circuit_output_validation' in…
LeilaWang May 26, 2024
4f54da1
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 27, 2024
7b9504e
Fix after merge.
LeilaWang May 27, 2024
026f359
Update tests.
LeilaWang May 27, 2024
b47042e
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 27, 2024
7b4584b
Fix fixtures.
LeilaWang May 28, 2024
611726a
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 28, 2024
3dfd361
Move components to folder.
LeilaWang May 28, 2024
50702a7
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 28, 2024
7d06e86
Address feedback.
LeilaWang May 28, 2024
3c245ae
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 28, 2024
b97e523
Check note logs in private call data validator.
LeilaWang May 28, 2024
1901d3b
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 28, 2024
f3895fa
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 29, 2024
09805ad
Merge remote-tracking branch 'origin/master' into lw/circuit_output_v…
LeilaWang May 29, 2024
02fd639
Fix.
LeilaWang May 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use dep::private_kernel_lib::PrivateKernelInitCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
input.simulate()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ use dep::types::PrivateKernelCircuitPublicInputs;

#[recursive]
fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
input.execute()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use dep::private_kernel_lib::PrivateKernelInnerCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
input.simulate()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ use dep::types::PrivateKernelCircuitPublicInputs;

#[recursive]
fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
input.execute()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod private_kernel_circuit_output_validator;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod components;
mod kernel_circuit_public_inputs_composer;
mod private_call_data_validator;
mod private_kernel_circuit_public_inputs_composer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ impl PrivateCallDataValidator {
assert_eq(
self.array_lengths.new_l2_to_l1_msgs, 0, "new_l2_to_l1_msgs must be empty for static calls"
);
assert_eq(
self.array_lengths.note_encrypted_logs_hashes, 0, "note_encrypted_logs_hashes must be empty for static calls"
);
assert_eq(
self.array_lengths.encrypted_logs_hashes, 0, "encrypted_logs_hashes must be empty for static calls"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use dep::types::{
abis::{
call_request::CallRequest, combined_constant_data::CombinedConstantData,
kernel_circuit_public_inputs::{PrivateKernelCircuitPublicInputs, PrivateKernelCircuitPublicInputsBuilder},
max_block_number::MaxBlockNumber, nullifier::Nullifier, note_hash::ScopedNoteHash,
log_hash::NoteLogHash,
max_block_number::MaxBlockNumber, nullifier::{Nullifier, ScopedNullifier},
note_hash::ScopedNoteHash, log_hash::NoteLogHash,
private_circuit_public_inputs::{PrivateCircuitPublicInputs, PrivateCircuitPublicInputsArrayLengths}
},
address::AztecAddress,
Expand All @@ -25,6 +25,10 @@ struct DataSource {
public_teardown_call_request: CallRequest,
}

pub fn create_first_nullifier(tx_request: TxRequest) -> ScopedNullifier {
Nullifier { value: tx_request.hash(), note_hash: 0, counter: 0 }.scope(AztecAddress::zero())
}

struct PrivateKernelCircuitPublicInputsComposer {
public_inputs: PrivateKernelCircuitPublicInputsBuilder,
}
Expand All @@ -38,10 +42,8 @@ impl PrivateKernelCircuitPublicInputsComposer {
tx_request.tx_context,
);

public_inputs.min_revertible_side_effect_counter = private_call_public_inputs.min_revertible_side_effect_counter;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning the min counter in propagate_from_private_call instead, which is run by both init and inner.


// Since it's the first iteration, we need to push the the tx hash nullifier into the `new_nullifiers` array
public_inputs.end.new_nullifiers.push(Nullifier { value: tx_request.hash(), note_hash: 0, counter: 0 }.scope(AztecAddress::zero()));
// Since it's the first iteration, we need to push the tx hash nullifier into the `new_nullifiers` array
public_inputs.end.new_nullifiers.push(create_first_nullifier(tx_request));
// Note that we do not need to nullify the transaction request nonce anymore.
// Should an account want to additionally use nonces for replay protection or handling cancellations,
// they will be able to do so in the account contract logic:
Expand Down Expand Up @@ -97,7 +99,16 @@ impl PrivateKernelCircuitPublicInputsComposer {
public_call_requests,
public_teardown_call_request
};
self.propagate_from_private_call(source);

*self
}

pub fn finish(self) -> PrivateKernelCircuitPublicInputs {
self.public_inputs.finish()
}

fn propagate_from_private_call(&mut self, source: DataSource) {
self.propagate_max_block_number(source);
self.propagate_note_hash_read_requests(source);
self.propagate_nullifier_read_requests(source);
Expand All @@ -111,19 +122,15 @@ impl PrivateKernelCircuitPublicInputsComposer {
self.propagate_public_teardown_call_request(source);
self.propagate_fee_payer(source);
self.propagate_min_revertible_side_effect_counter(source);

*self
}

pub fn finish(self) -> PrivateKernelCircuitPublicInputs {
self.public_inputs.finish()
}

fn propagate_min_revertible_side_effect_counter(&mut self, source: DataSource) {
self.public_inputs.min_revertible_side_effect_counter = if self.public_inputs.min_revertible_side_effect_counter > 0 {
self.public_inputs.min_revertible_side_effect_counter
if self.public_inputs.min_revertible_side_effect_counter != 0 {
assert(
source.private_call_public_inputs.min_revertible_side_effect_counter == 0, "cannot overwrite non-zero min_revertible_side_effect_counter"
);
} else {
source.private_call_public_inputs.min_revertible_side_effect_counter
self.public_inputs.min_revertible_side_effect_counter = source.private_call_public_inputs.min_revertible_side_effect_counter;
};
}

Expand Down Expand Up @@ -204,6 +211,7 @@ impl PrivateKernelCircuitPublicInputsComposer {
self.public_inputs.end.encrypted_logs_hashes.push(log.scope(source.storage_contract_address));
}
}

let unencrypted_logs = source.private_call_public_inputs.unencrypted_logs_hashes;
for i in 0..unencrypted_logs.len() {
let log = unencrypted_logs[i];
Expand All @@ -213,15 +221,13 @@ impl PrivateKernelCircuitPublicInputsComposer {
}

let note_logs = source.private_call_public_inputs.note_encrypted_logs_hashes;
let new_note_hashes = self.public_inputs.end.new_note_hashes;
for i in 0..note_logs.len() {
if !is_empty(note_logs[i]) {
let note_index = self.match_log_to_note(note_logs[i]);
assert(
note_index < MAX_NEW_NOTE_HASHES_PER_TX, "Could not find note hash linked to note log."
);
assert(
note_logs[i].note_hash_counter
== self.public_inputs.end.new_note_hashes.get_unchecked(note_index).counter(), "Could not find note hash linked to note log."
assert(note_index < new_note_hashes.len(), "Could not find note hash linked to note log");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check against the number of non-empty items. Otherwise, we would be allowing a log to link to counter 0.

assert_eq(
note_logs[i].note_hash_counter, new_note_hashes.get_unchecked(note_index).counter(), "Could not find note hash linked to note log"
);
self.public_inputs.end.note_encrypted_logs_hashes.push(note_logs[i]);
}
Expand Down
Loading