Skip to content

Commit

Permalink
Merge branch 'master' into 04-26-feat_variable_base_scalar_mul_blacbo…
Browse files Browse the repository at this point in the history
…x_func
  • Loading branch information
benesjan authored Apr 29, 2024
2 parents 9448729 + 2b8b2c3 commit bb8be33
Show file tree
Hide file tree
Showing 122 changed files with 3,075 additions and 1,686 deletions.
18 changes: 8 additions & 10 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use dep::protocol_types::{
private_circuit_public_inputs::PrivateCircuitPublicInputs,
public_call_stack_item::PublicCallStackItem,
public_circuit_public_inputs::PublicCircuitPublicInputs, read_request::ReadRequest,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
note_hash::NoteHash, nullifier::Nullifier, side_effect::SideEffect
},
address::{AztecAddress, EthAddress},
constants::{
Expand Down Expand Up @@ -53,8 +53,8 @@ struct PrivateContext {
nullifier_read_requests: BoundedVec<ReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL>,
nullifier_key_validation_requests: BoundedVec<NullifierKeyValidationRequest, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL>,

new_note_hashes: BoundedVec<SideEffect, MAX_NEW_NOTE_HASHES_PER_CALL>,
new_nullifiers: BoundedVec<SideEffectLinkedToNoteHash, MAX_NEW_NULLIFIERS_PER_CALL>,
new_note_hashes: BoundedVec<NoteHash, MAX_NEW_NOTE_HASHES_PER_CALL>,
new_nullifiers: BoundedVec<Nullifier, MAX_NEW_NULLIFIERS_PER_CALL>,

private_call_stack_hashes : BoundedVec<Field, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,
public_call_stack_hashes : BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
Expand Down Expand Up @@ -99,14 +99,12 @@ impl ContextInterface for PrivateContext {
}

fn push_new_note_hash(&mut self, note_hash: Field) {
let side_effect = SideEffect { value: note_hash, counter: self.side_effect_counter };
self.new_note_hashes.push(side_effect);
self.new_note_hashes.push(NoteHash { value: note_hash, counter: self.side_effect_counter });
self.side_effect_counter = self.side_effect_counter + 1;
}

fn push_new_nullifier(&mut self, nullifier: Field, nullified_commitment: Field) {
let side_effect = SideEffectLinkedToNoteHash { value: nullifier, note_hash: nullified_commitment, counter: self.side_effect_counter };
self.new_nullifiers.push(side_effect);
fn push_new_nullifier(&mut self, nullifier: Field, nullified_note_hash: Field) {
self.new_nullifiers.push(Nullifier { value: nullifier, note_hash: nullified_note_hash, counter: self.side_effect_counter });
self.side_effect_counter = self.side_effect_counter + 1;
}
}
Expand Down Expand Up @@ -492,8 +490,8 @@ impl PrivateContext {
contract_storage_update_requests: [StorageUpdateRequest::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL],
contract_storage_reads: [StorageRead::empty(); MAX_PUBLIC_DATA_READS_PER_CALL],
public_call_stack_hashes: [0; MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL],
new_note_hashes: [SideEffect::empty(); MAX_NEW_NOTE_HASHES_PER_CALL],
new_nullifiers: [SideEffectLinkedToNoteHash::empty(); MAX_NEW_NULLIFIERS_PER_CALL],
new_note_hashes: [NoteHash::empty(); MAX_NEW_NOTE_HASHES_PER_CALL],
new_nullifiers: [Nullifier::empty(); MAX_NEW_NULLIFIERS_PER_CALL],
new_l2_to_l1_msgs: [L2ToL1Message::empty(); MAX_NEW_L2_TO_L1_MSGS_PER_CALL],
start_side_effect_counter: 0,
end_side_effect_counter: 0,
Expand Down
16 changes: 7 additions & 9 deletions noir-projects/aztec-nr/aztec/src/context/public_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use dep::protocol_types::{
private_circuit_public_inputs::PrivateCircuitPublicInputs,
public_call_stack_item::PublicCallStackItem,
public_circuit_public_inputs::PublicCircuitPublicInputs, read_request::ReadRequest,
side_effect::{SideEffect, SideEffectLinkedToNoteHash}
note_hash::NoteHash, nullifier::Nullifier, side_effect::SideEffect
},
hash::silo_nullifier, address::{AztecAddress, EthAddress},
constants::{
Expand All @@ -40,8 +40,8 @@ struct PublicContext {
contract_storage_reads: BoundedVec<StorageRead, MAX_PUBLIC_DATA_READS_PER_CALL>,
public_call_stack_hashes: BoundedVec<Field, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,

new_note_hashes: BoundedVec<SideEffect, MAX_NEW_NOTE_HASHES_PER_CALL>,
new_nullifiers: BoundedVec<SideEffectLinkedToNoteHash, MAX_NEW_NULLIFIERS_PER_CALL>,
new_note_hashes: BoundedVec<NoteHash, MAX_NEW_NOTE_HASHES_PER_CALL>,
new_nullifiers: BoundedVec<Nullifier, MAX_NEW_NULLIFIERS_PER_CALL>,

new_l2_to_l1_msgs: BoundedVec<L2ToL1Message, MAX_NEW_L2_TO_L1_MSGS_PER_CALL>,

Expand Down Expand Up @@ -204,18 +204,16 @@ impl ContextInterface for PublicContext {
}

fn push_new_note_hash(&mut self, note_hash: Field) {
let side_effect = SideEffect { value: note_hash, counter: self.side_effect_counter };
self.new_note_hashes.push(side_effect);
self.new_note_hashes.push(NoteHash { value: note_hash, counter: self.side_effect_counter });
self.side_effect_counter = self.side_effect_counter + 1;
}

fn push_new_nullifier(&mut self, nullifier: Field, _nullified_commitment: Field) {
let side_effect = SideEffectLinkedToNoteHash {
fn push_new_nullifier(&mut self, nullifier: Field, _nullified_note_hash: Field) {
self.new_nullifiers.push(Nullifier {
value: nullifier,
note_hash: 0, // cannot nullify pending notes in public context
counter: self.side_effect_counter
};
self.new_nullifiers.push(side_effect);
});
self.side_effect_counter = self.side_effect_counter + 1;
}
}
Expand Down
8 changes: 6 additions & 2 deletions noir-projects/aztec-nr/aztec/src/note/lifecycle.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ pub fn create_note<Note, N>(

// TODO: Strong typing required because of https://github.com/noir-lang/noir/issues/4088
let serialized_note: [Field; N] = Note::serialize_content(*note);
let note_hash_counter = context.side_effect_counter;
assert(
notify_created_note(
storage_slot,
Note::get_note_type_id(),
serialized_note,
inner_note_hash
inner_note_hash,
note_hash_counter
)
== 0
);
Expand Down Expand Up @@ -69,7 +71,9 @@ pub fn destroy_note<Note, N>(context: &mut PrivateContext, note: Note) where Not
// TODO(1718): Can we reuse the note hash computed in `compute_nullifier`?
consumed_note_hash = compute_note_hash_for_consumption(note);
}
assert(notify_nullified_note(nullifier, consumed_note_hash) == 0);

let nullifier_counter = context.side_effect_counter;
assert(notify_nullified_note(nullifier, consumed_note_hash, nullifier_counter) == 0);

context.push_new_nullifier(nullifier, consumed_note_hash)
}
28 changes: 22 additions & 6 deletions noir-projects/aztec-nr/aztec/src/oracle/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,39 @@ fn notify_created_note_oracle<N>(
_storage_slot: Field,
_note_type_id: Field,
_serialized_note: [Field; N],
_inner_note_hash: Field
_inner_note_hash: Field,
_counter: u32
) -> Field {}

unconstrained pub fn notify_created_note<N>(
storage_slot: Field,
note_type_id: Field,
serialized_note: [Field; N],
inner_note_hash: Field
inner_note_hash: Field,
counter: u32
) -> Field {
notify_created_note_oracle(storage_slot, note_type_id, serialized_note, inner_note_hash)
notify_created_note_oracle(
storage_slot,
note_type_id,
serialized_note,
inner_note_hash,
counter
)
}

#[oracle(notifyNullifiedNote)]
fn notify_nullified_note_oracle<N>(_nullifier: Field, _inner_note_hash: Field) -> Field {}
fn notify_nullified_note_oracle<N>(
_nullifier: Field,
_inner_note_hash: Field,
_counter: u32
) -> Field {}

unconstrained pub fn notify_nullified_note<N>(nullifier: Field, inner_note_hash: Field) -> Field {
notify_nullified_note_oracle(nullifier, inner_note_hash)
unconstrained pub fn notify_nullified_note<N>(
nullifier: Field,
inner_note_hash: Field,
counter: u32
) -> Field {
notify_nullified_note_oracle(nullifier, inner_note_hash, counter)
}

#[oracle(getNotes)]
Expand Down
8 changes: 2 additions & 6 deletions noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use dep::protocol_types::{
constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
abis::side_effect::{SideEffect, SideEffectLinkedToNoteHash}
};
use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, abis::side_effect::SideEffect};
use crate::context::{PrivateContext, PublicContext, Context};
use crate::note::{
constants::MAX_NOTES_PER_PAGE,
lifecycle::{create_note, create_note_hash_from_public, destroy_note},
constants::MAX_NOTES_PER_PAGE, lifecycle::{create_note, create_note_hash_from_public, destroy_note},
note_getter::{get_notes, view_notes}, note_getter_options::NoteGetterOptions,
note_header::NoteHeader, note_interface::NoteInterface, note_viewer_options::NoteViewerOptions,
utils::compute_note_hash_for_consumption
Expand Down
Loading

0 comments on commit bb8be33

Please sign in to comment.