From 54c0cd15988be43595e7f15503aca88bb06d099b Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Sun, 8 Dec 2024 21:01:06 +0000 Subject: [PATCH 01/29] initial attempt to rm logs, with some failing tests --- avm-transpiler/Cargo.lock | 1 - boxes/boxes/react/src/contracts/src/main.nr | 6 +- boxes/boxes/vanilla/src/contracts/src/main.nr | 6 +- .../aztec/src/context/private_context.nr | 3 + .../encrypted_event_emission.nr | 32 +--- .../encrypted_logs/encrypted_note_emission.nr | 38 ++--- .../aztec/src/encrypted_logs/payload.nr | 150 ++---------------- .../aztec-nr/aztec/src/macros/notes/mod.nr | 9 +- .../aztec-nr/aztec/src/note/lifecycle.nr | 4 + .../src/easy_private_uint.nr | 37 +---- .../aztec-nr/value-note/src/utils.nr | 18 +-- .../app_subscription_contract/src/main.nr | 14 +- .../benchmarking_contract/src/main.nr | 20 +-- .../contracts/card_game_contract/src/cards.nr | 3 - .../contracts/child_contract/src/main.nr | 4 - .../src/main.nr | 1 + .../contracts/counter_contract/src/main.nr | 17 +- .../crowdfunding_contract/src/main.nr | 3 - .../docs_example_contract/src/main.nr | 14 -- .../easy_private_token_contract/src/main.nr | 19 +-- .../ecdsa_k_account_contract/src/main.nr | 6 - .../ecdsa_r_account_contract/src/main.nr | 6 - .../contracts/escrow_contract/src/main.nr | 3 - .../inclusion_proofs_contract/src/main.nr | 7 +- .../contracts/nft_contract/src/main.nr | 17 +- .../pending_note_hashes_contract/src/main.nr | 112 ++++--------- .../schnorr_account_contract/src/main.nr | 7 +- .../contracts/spam_contract/src/main.nr | 4 +- .../stateful_test_contract/src/main.nr | 20 +-- .../static_child_contract/src/main.nr | 14 +- .../contracts/test_contract/src/main.nr | 39 ++--- .../contracts/test_log_contract/src/main.nr | 33 +--- .../token_blacklist_contract/src/main.nr | 23 +-- .../contracts/token_contract/src/main.nr | 31 +--- .../aztec.js/src/wallet/base_wallet.ts | 5 - yarn-project/bot/src/bot.ts | 2 +- yarn-project/bot/src/factory.ts | 4 +- .../circuit-types/src/interfaces/pxe.test.ts | 11 +- .../circuit-types/src/interfaces/pxe.ts | 14 +- .../l1_payload/encrypted_log_payload.test.ts | 90 ++++------- .../logs/l1_payload/encrypted_log_payload.ts | 138 +--------------- .../src/logs/l1_payload/l1_event_payload.ts | 12 -- .../src/logs/l1_payload/l1_note_payload.ts | 31 ---- .../l1_payload/shared_secret_derivation.ts | 20 +-- yarn-project/circuit-types/src/notes/index.ts | 1 - .../src/notes/outgoing_notes_filter.ts | 28 ---- .../cli/src/cmds/devnet/bootstrap_network.ts | 2 +- .../end-to-end/src/benchmarks/utils.ts | 5 +- .../end-to-end/src/e2e_2_pxes.test.ts | 9 +- .../end-to-end/src/e2e_block_building.test.ts | 12 +- .../contract_class_registration.test.ts | 4 +- .../e2e_deploy_contract/deploy_method.test.ts | 8 +- .../private_initialization.test.ts | 26 +-- .../end-to-end/src/e2e_event_logs.test.ts | 34 +--- .../src/e2e_fees/dapp_subscription.test.ts | 1 - .../end-to-end/src/e2e_fees/fees_test.ts | 4 +- yarn-project/end-to-end/src/e2e_keys.test.ts | 4 +- .../end-to-end/src/e2e_note_getter.test.ts | 17 +- .../e2e_pending_note_hashes_contract.test.ts | 45 +++--- .../end-to-end/src/e2e_static_calls.test.ts | 11 +- .../e2e_public_testnet_transfer.test.ts | 3 +- .../pxe/src/database/kv_pxe_database.ts | 94 +---------- yarn-project/pxe/src/database/pxe_database.ts | 12 +- .../src/database/pxe_database_test_suite.ts | 79 +-------- .../produce_note_daos.ts | 51 +----- .../pxe/src/pxe_service/pxe_service.ts | 30 +--- .../pxe/src/simulator_oracle/index.ts | 45 ++---- .../simulator_oracle/simulator_oracle.test.ts | 91 +---------- .../src/client/private_execution.test.ts | 36 +---- 69 files changed, 316 insertions(+), 1384 deletions(-) delete mode 100644 yarn-project/circuit-types/src/notes/outgoing_notes_filter.ts diff --git a/avm-transpiler/Cargo.lock b/avm-transpiler/Cargo.lock index bdac1771a70..4da74e41190 100644 --- a/avm-transpiler/Cargo.lock +++ b/avm-transpiler/Cargo.lock @@ -948,7 +948,6 @@ dependencies = [ "acvm", "iter-extended", "jsonrpc", - "regex", "serde", "serde_json", "thiserror", diff --git a/boxes/boxes/react/src/contracts/src/main.nr b/boxes/boxes/react/src/contracts/src/main.nr index f4924981e8e..05f726cab41 100644 --- a/boxes/boxes/react/src/contracts/src/main.nr +++ b/boxes/boxes/react/src/contracts/src/main.nr @@ -25,8 +25,7 @@ contract BoxReact { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner); - let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); + numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender())); } #[private] @@ -37,8 +36,7 @@ contract BoxReact { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner); - let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); + numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender())); } unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote { diff --git a/boxes/boxes/vanilla/src/contracts/src/main.nr b/boxes/boxes/vanilla/src/contracts/src/main.nr index c27e8f81a74..0cef33917db 100644 --- a/boxes/boxes/vanilla/src/contracts/src/main.nr +++ b/boxes/boxes/vanilla/src/contracts/src/main.nr @@ -25,8 +25,7 @@ contract Vanilla { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner); - let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); + numbers.at(owner).initialize(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender())); } #[private] @@ -37,8 +36,7 @@ contract Vanilla { let numbers = storage.numbers; let mut new_number = ValueNote::new(number, owner); - let owner_ovpk_m = get_public_keys(owner).ovpk_m; - numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner_ovpk_m, owner, context.msg_sender())); + numbers.at(owner).replace(&mut new_number).emit(encode_and_encrypt_note(&mut context, owner, context.msg_sender())); } unconstrained fn getNumber(owner: AztecAddress) -> pub ValueNote { diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index b2c94e61427..a9e80762966 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -1,3 +1,5 @@ +use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; + use crate::{ context::{inputs::PrivateContextInputs, packed_returns::PackedReturns}, hash::{ArgsHasher, hash_args_array}, @@ -137,6 +139,7 @@ impl PrivateContext { pub fn push_note_hash(&mut self, note_hash: Field) { self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); + debug_log_format("\nPushed new note hash: (note_hash:{0}, counter: {1})", [note_hash, (self.side_effect_counter - 1) as Field]); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr index b80e3c90d24..a0fd3619a3c 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr @@ -1,17 +1,13 @@ use crate::{ context::PrivateContext, encrypted_logs::payload::compute_private_log_payload, - event::event_interface::EventInterface, keys::getters::get_ovsk_app, -}; -use dep::protocol_types::{ - address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS, public_keys::OvpkM, + event::event_interface::EventInterface, }; +use dep::protocol_types::{address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS}; /// Computes private event log payload and a log hash fn compute_payload( context: PrivateContext, event: Event, - ovsk_app: Field, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, ) -> [Field; PRIVATE_LOG_SIZE_IN_FIELDS] @@ -21,52 +17,40 @@ where let contract_address: AztecAddress = context.this_address(); let plaintext = event.to_be_bytes(); - compute_private_log_payload( - contract_address, - ovsk_app, - ovpk, - recipient, - sender, - plaintext, - ) + compute_private_log_payload(contract_address, recipient, sender, plaintext) } unconstrained fn compute_payload_unconstrained( context: PrivateContext, event: Event, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, ) -> [Field; PRIVATE_LOG_SIZE_IN_FIELDS] where Event: EventInterface, { - let ovsk_app = get_ovsk_app(ovpk.hash()); - compute_payload(context, event, ovsk_app, ovpk, recipient, sender) + compute_payload(context, event, recipient, sender) } pub fn encode_and_encrypt_event( context: &mut PrivateContext, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, -) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](Event) -> () +) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](Event) -> () where Event: EventInterface, { |e: Event| { - let ovsk_app: Field = context.request_ovsk_app(ovpk.hash()); - let encrypted_log = compute_payload(*context, e, ovsk_app, ovpk, recipient, sender); + let encrypted_log = compute_payload(*context, e, recipient, sender); context.emit_private_log(encrypted_log); } } pub fn encode_and_encrypt_event_unconstrained( context: &mut PrivateContext, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, -) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](Event) -> () +) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](Event) -> () where Event: EventInterface, { @@ -74,7 +58,7 @@ where // Unconstrained logs have both their content and encryption unconstrained - it could occur that the // recipient is unable to decrypt the payload. let encrypted_log = - unsafe { compute_payload_unconstrained(*context, e, ovpk, recipient, sender) }; + unsafe { compute_payload_unconstrained(*context, e, recipient, sender) }; context.emit_private_log(encrypted_log); } } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index a089813de5f..b8109382a57 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -1,20 +1,18 @@ +use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; + use crate::{ context::PrivateContext, encrypted_logs::payload::compute_private_log_payload, - keys::getters::get_ovsk_app, note::{note_emission::NoteEmission, note_interface::NoteInterface}, }; use dep::protocol_types::{ abis::note_hash::NoteHash, address::AztecAddress, constants::PRIVATE_LOG_SIZE_IN_FIELDS, - public_keys::OvpkM, }; /// Computes private note log payload fn compute_payload( context: PrivateContext, note: Note, - ovsk_app: Field, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, ) -> ([Field; PRIVATE_LOG_SIZE_IN_FIELDS], u32) @@ -25,6 +23,9 @@ where let note_hash_counter = note_header.note_hash_counter; let storage_slot = note_header.storage_slot; + debug_log_format("\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", [note_hash_counter as Field, storage_slot]); + + // TODO(#8589): use typesystem to skip this check when not needed let note_exists = context.note_hashes.storage().any(|n: NoteHash| n.counter == note_hash_counter); @@ -34,14 +35,7 @@ where let plaintext = note.to_be_bytes(storage_slot); - let payload = compute_private_log_payload( - contract_address, - ovsk_app, - ovpk, - recipient, - sender, - plaintext, - ); + let payload = compute_private_log_payload(contract_address, recipient, sender, plaintext); (payload, note_hash_counter) } @@ -49,15 +43,13 @@ where unconstrained fn compute_payload_unconstrained( context: PrivateContext, note: Note, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, ) -> ([Field; PRIVATE_LOG_SIZE_IN_FIELDS], u32) where Note: NoteInterface, { - let ovsk_app = get_ovsk_app(ovpk.hash()); - compute_payload(context, note, ovsk_app, ovpk, recipient, sender) + compute_payload(context, note, recipient, sender) } // This function seems to be affected by the following Noir bug: @@ -65,30 +57,26 @@ where // If you get weird behavior it might be because of it. pub fn encode_and_encrypt_note( context: &mut PrivateContext, - ovpk: OvpkM, recipient: AztecAddress, - // TODO: We need this because to compute a tagging secret, we require a sender. Should we have the tagging secret oracle take a ovpk_m as input instead of the address? + // We need this because to compute a tagging secret, we require a sender: sender: AztecAddress, -) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission) -> () +) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](NoteEmission) -> () where Note: NoteInterface, { |e: NoteEmission| { - let ovsk_app: Field = context.request_ovsk_app(ovpk.hash()); - let (encrypted_log, note_hash_counter) = - compute_payload(*context, e.note, ovsk_app, ovpk, recipient, sender); + compute_payload(*context, e.note, recipient, sender); context.emit_raw_note_log(encrypted_log, note_hash_counter); } } pub fn encode_and_encrypt_note_unconstrained( context: &mut PrivateContext, - ovpk: OvpkM, recipient: AztecAddress, - // TODO: We need this because to compute a tagging secret, we require a sender. Should we have the tagging secret oracle take a ovpk_m as input instead of the address? + // We need this because to compute a tagging secret, we require a sender: sender: AztecAddress, -) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission) -> () +) -> fn[(&mut PrivateContext, AztecAddress, AztecAddress)](NoteEmission) -> () where Note: NoteInterface, { @@ -104,7 +92,7 @@ where // return the log from this function to the app, otherwise it could try to do stuff with it and then that might // be wrong. let (encrypted_log, note_hash_counter) = - unsafe { compute_payload_unconstrained(*context, e.note, ovpk, recipient, sender) }; + unsafe { compute_payload_unconstrained(*context, e.note, recipient, sender) }; context.emit_raw_note_log(encrypted_log, note_hash_counter); } } diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index e93cb55b3a3..43033a5e984 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -1,9 +1,9 @@ use dep::protocol_types::{ address::AztecAddress, constants::{GENERATOR_INDEX__SYMMETRIC_KEY, PRIVATE_LOG_SIZE_IN_FIELDS}, - hash::{poseidon2_hash, poseidon2_hash_with_separator}, + hash::poseidon2_hash, point::Point, - public_keys::{AddressPoint, OvpkM}, + public_keys::AddressPoint, scalar::Scalar, utils::arrays::array_concat, }; @@ -27,15 +27,11 @@ global ENCRYPTED_PAYLOAD_SIZE_IN_BYTES: u32 = (PRIVATE_LOG_SIZE_IN_FIELDS - 1) * comptime global HEADER_SIZE: u32 = 48; -comptime global OUTGOING_BODY_SIZE: u32 = 112; - // Bytes padded to the overhead, so that the size of the incoming body ciphertext will be a multiple of 16. comptime global OVERHEAD_PADDING: u32 = 15; pub comptime global OVERHEAD_SIZE: u32 = 32 /* eph_pk */ + HEADER_SIZE /* incoming_header */ - + HEADER_SIZE /* outgoing_header */ - + OUTGOING_BODY_SIZE /* outgoing_body */ + OVERHEAD_PADDING /* padding */; global PLAINTEXT_LENGTH_SIZE: u32 = 2; @@ -52,8 +48,6 @@ global MAX_PRIVATE_LOG_PLAINTEXT_SIZE_IN_BYTES: u32 = pub fn compute_private_log_payload( contract_address: AztecAddress, - ovsk_app: Field, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, plaintext: [u8; P], @@ -65,13 +59,8 @@ pub fn compute_private_log_payload( let extended_plaintext: [u8; MAX_PRIVATE_LOG_PLAINTEXT_SIZE_IN_BYTES + PLAINTEXT_LENGTH_SIZE] = extend_private_log_plaintext(plaintext); - let encrypted: [u8; ENCRYPTED_PAYLOAD_SIZE_IN_BYTES] = compute_encrypted_log( - contract_address, - ovsk_app, - ovpk, - recipient, - extended_plaintext, - ); + let encrypted: [u8; ENCRYPTED_PAYLOAD_SIZE_IN_BYTES] = + compute_encrypted_log(contract_address, recipient, extended_plaintext); // We assume that the sender wants for the recipient to find the tagged note, and therefore that they will cooperate // and use the correct tag. Usage of a bad tag will result in the recipient not being able to find the note @@ -84,21 +73,14 @@ pub fn compute_private_log_payload( pub fn compute_partial_public_log_payload( contract_address: AztecAddress, - ovsk_app: Field, - ovpk: OvpkM, recipient: AztecAddress, sender: AztecAddress, plaintext: [u8; P], ) -> [u8; M] { let extended_plaintext: [u8; P + PLAINTEXT_LENGTH_SIZE] = extend_private_log_plaintext(plaintext); - let encrypted: [u8; M - 32] = compute_encrypted_log( - contract_address, - ovsk_app, - ovpk, - recipient, - extended_plaintext, - ); + let encrypted: [u8; M - 32] = + compute_encrypted_log(contract_address, recipient, extended_plaintext); // We assume that the sender wants for the recipient to find the tagged note, and therefore that they will cooperate // and use the correct tag. Usage of a bad tag will result in the recipient not being able to find the note @@ -128,8 +110,6 @@ pub fn compute_partial_public_log_payload( fn compute_encrypted_log( contract_address: AztecAddress, - ovsk_app: Field, - ovpk: OvpkM, recipient: AztecAddress, plaintext: [u8; P], ) -> [u8; M] { @@ -139,11 +119,8 @@ fn compute_encrypted_log( let incoming_header_ciphertext: [u8; 48] = header.compute_ciphertext(eph_sk, recipient.to_address_point()); - let outgoing_header_ciphertext: [u8; 48] = header.compute_ciphertext(eph_sk, ovpk); let incoming_body_ciphertext = compute_incoming_body_ciphertext(plaintext, eph_sk, recipient.to_address_point()); - let outgoing_body_ciphertext: [u8; 112] = - compute_outgoing_body_ciphertext(recipient, fr_to_fq(ovsk_app), eph_sk, eph_pk); let mut encrypted_bytes = [0; M]; let mut offset = 0; @@ -156,18 +133,10 @@ fn compute_encrypted_log( offset += 32; // incoming_header - // outgoing_header for i in 0..HEADER_SIZE { encrypted_bytes[offset + i] = incoming_header_ciphertext[i]; - encrypted_bytes[offset + HEADER_SIZE + i] = outgoing_header_ciphertext[i]; } - offset += HEADER_SIZE * 2; - - // outgoing_body - for i in 0..OUTGOING_BODY_SIZE { - encrypted_bytes[offset + i] = outgoing_body_ciphertext[i]; - } - offset += OUTGOING_BODY_SIZE; + offset += HEADER_SIZE; // Padding. offset += OVERHEAD_PADDING; @@ -250,61 +219,13 @@ pub fn compute_incoming_body_ciphertext( aes128_encrypt(plaintext, iv, sym_key) } -/// Encrypts ephemeral secret key and recipient's address point --> with this information the recipient of outgoing will -/// be able to derive the key with which the incoming log can be decrypted. -pub fn compute_outgoing_body_ciphertext( - recipient: AztecAddress, - ovsk_app: Scalar, - eph_sk: Scalar, - eph_pk: Point, -) -> [u8; OUTGOING_BODY_SIZE] { - // Again, we could compute `eph_pk` here, but we keep the interface more similar - // and also make it easier to optimise it later as we just pass it along - let mut buffer = [0 as u8; 96]; - - let serialized_eph_sk_high: [u8; 32] = eph_sk.hi.to_be_bytes(); - let serialized_eph_sk_low: [u8; 32] = eph_sk.lo.to_be_bytes(); - - let address_bytes: [u8; 32] = recipient.to_field().to_be_bytes(); - let serialized_recipient_address_point = - point_to_bytes(recipient.to_address_point().to_point()); - - for i in 0..16 { - buffer[i] = serialized_eph_sk_high[i + 16]; - buffer[i + 16] = serialized_eph_sk_low[i + 16]; - } - for i in 0..32 { - buffer[i + 32] = address_bytes[i]; - buffer[i + 64] = serialized_recipient_address_point[i]; - } - - // We compute the symmetric key using poseidon. - let full_key: [u8; 32] = poseidon2_hash_with_separator( - [ovsk_app.hi, ovsk_app.lo, eph_pk.x, eph_pk.y], - GENERATOR_INDEX__SYMMETRIC_KEY as Field, - ) - .to_be_bytes(); - - let mut sym_key = [0; 16]; - let mut iv = [0; 16]; - - for i in 0..16 { - sym_key[i] = full_key[i]; - iv[i] = full_key[i + 16]; - } - aes128_encrypt(buffer, iv, sym_key).as_array() -} - mod test { use crate::encrypted_logs::payload::{ - compute_incoming_body_ciphertext, compute_outgoing_body_ciphertext, - compute_private_log_payload, MAX_PRIVATE_LOG_PLAINTEXT_SIZE_IN_BYTES, - }; - use dep::protocol_types::{ - address::AztecAddress, point::Point, public_keys::OvpkM, scalar::Scalar, + compute_incoming_body_ciphertext, compute_private_log_payload, + MAX_PRIVATE_LOG_PLAINTEXT_SIZE_IN_BYTES, }; + use dep::protocol_types::{address::AztecAddress, point::Point, scalar::Scalar}; use protocol_types::public_keys::AddressPoint; - use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; use std::test::OracleMock; #[test] @@ -313,14 +234,6 @@ mod test { let contract_address = AztecAddress::from_field( 0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04, ); - let ovsk_app = 0x191ac5e29bbc8f80f29ed06b75eaf30c036ed7952d844833860c527077c8c3b4; - let ovpk_m = OvpkM { - inner: Point { - x: 0x07f696b8b233de2c1935e43c793399586f532da5ff7c0356636a75acb862e964, - y: 0x156e8a3e42bfca3663936ba98c7fd26386a14657c23b5f5146f1a94b6c465154, - is_infinite: false, - }, - }; let plaintext = [ 0, 0, 0, 1, 48, 22, 64, 206, 234, 117, 131, 145, 178, 225, 97, 201, 44, 5, 19, 241, 41, @@ -351,14 +264,7 @@ mod test { let _ = OracleMock::mock("incrementAppTaggingSecretIndexAsSender").returns(()); - let payload = compute_private_log_payload( - contract_address, - ovsk_app, - ovpk_m, - recipient, - sender, - plaintext, - ); + let payload = compute_private_log_payload(contract_address, recipient, sender, plaintext); // The following value was generated by `encrypted_log_payload.test.ts` // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. @@ -434,38 +340,4 @@ mod test { assert_eq(ciphertext[i], note_body_ciphertext_from_typescript[i]); } } - - #[test] - fn test_encrypted_log_outgoing_body_matches_typescript() { - let eph_sk = Scalar { - lo: 0x00000000000000000000000000000000d0d302ee245dfaf2807e604eec4715fe, - hi: 0x000000000000000000000000000000000f096b423017226a18461115fa8d34bb, - }; - - let sender_ovsk_app = Scalar { - lo: 0x0000000000000000000000000000000074d2e28c6bc5176ac02cf7c7d36a444e, - hi: 0x00000000000000000000000000000000089c6887cb1446d86c64e81afc78048b, - }; - - let eph_pk = derive_public_key(eph_sk); - let recipient = AztecAddress::from_field( - 0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70c, - ); - - let ciphertext = - compute_outgoing_body_ciphertext(recipient, sender_ovsk_app, eph_sk, eph_pk); - - // The following value was generated by `encrypted_log_payload.test.ts` - // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. - let outgoing_body_ciphertext_from_typescript = [ - 97, 221, 53, 168, 242, 56, 217, 184, 114, 127, 137, 98, 31, 63, 86, 179, 139, 198, 162, - 162, 216, 158, 255, 205, 90, 212, 141, 55, 9, 245, 6, 146, 202, 137, 129, 36, 190, 31, - 17, 89, 151, 203, 43, 196, 203, 233, 178, 79, 202, 70, 250, 182, 18, 191, 79, 42, 205, - 204, 145, 14, 13, 35, 255, 139, 142, 66, 193, 240, 175, 233, 180, 37, 153, 235, 41, 88, - 232, 52, 235, 213, 50, 26, 153, 227, 25, 242, 161, 92, 45, 152, 100, 106, 29, 192, 131, - 101, 121, 126, 31, 118, 191, 90, 238, 43, 24, 82, 49, 18, 199, 107, 83, 7, - ]; - - assert_eq(outgoing_body_ciphertext_from_typescript, ciphertext); - } } diff --git a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr index 43695823182..5d8aa114b09 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr @@ -392,12 +392,9 @@ comptime fn generate_multi_scalar_mul( /// } /// /// fn encrypt_log(self, context: &mut PrivateContext, recipient_keys: aztec::protocol_types::public_keys::PublicKeys, recipient: aztec::protocol_types::address::AztecAddress) -> [Field; 17] { -/// let ovsk_app: Field = context.request_ovsk_app(recipient_keys.ovpk_m.hash()); /// /// let encrypted_log_bytes: [u8; 513] = aztec::encrypted_logs::payload::compute_partial_public_log_payload( /// context.this_address(), -/// ovsk_app, -/// recipient_keys.ovpk_m, /// recipient, /// self.log_plaintext /// ); @@ -469,13 +466,9 @@ comptime fn generate_setup_payload( } } - pub fn encrypt_log(self, context: &mut PrivateContext, ovpk: aztec::protocol_types::public_keys::OvpkM, recipient: aztec::protocol_types::address::AztecAddress, sender: aztec::protocol_types::address::AztecAddress) -> [Field; $encrypted_log_field_length] { - let ovsk_app: Field = context.request_ovsk_app(ovpk.hash()); - + pub fn encrypt_log(self, context: &mut PrivateContext, recipient: aztec::protocol_types::address::AztecAddress, sender: aztec::protocol_types::address::AztecAddress) -> [Field; $encrypted_log_field_length] { let encrypted_log_bytes: [u8; $encrypted_log_byte_length] = aztec::encrypted_logs::payload::compute_partial_public_log_payload( context.this_address(), - ovsk_app, - ovpk, recipient, sender, self.log_plaintext, diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index d07e61e8b6b..e1e40597816 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -1,3 +1,5 @@ +use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; + use crate::context::{PrivateContext, PublicContext}; use crate::note::{ note_emission::NoteEmission, @@ -18,6 +20,8 @@ where let contract_address = (*context).this_address(); let note_hash_counter = context.side_effect_counter; + debug_log_format("\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", [note_hash_counter as Field, storage_slot]); + let header = NoteHeader { contract_address, storage_slot, nonce: 0, note_hash_counter }; note.set_header(header); let note_hash = note.compute_note_hash(); diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index d42e7c6d7ef..fdc752de0a9 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -1,7 +1,7 @@ use dep::aztec::{ context::PrivateContext, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, note::note_getter_options::NoteGetterOptions, - protocol_types::address::AztecAddress, state_vars::PrivateSet, + note::note_getter_options::NoteGetterOptions, protocol_types::address::AztecAddress, + state_vars::PrivateSet, }; use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; @@ -22,38 +22,18 @@ impl EasyPrivateUint { impl EasyPrivateUint<&mut PrivateContext> { // Very similar to `value_note::utils::increment`. - pub fn add( - self, - addend: u64, - owner: AztecAddress, - outgoing_viewer: AztecAddress, - sender: AztecAddress, - ) { - let outgoing_viewer_keys = get_public_keys(outgoing_viewer); + pub fn add(self, addend: u64, owner: AztecAddress, sender: AztecAddress) { // Creates new note for the owner. let mut addend_note = ValueNote::new(addend as Field, owner); // Insert the new note to the owner's set of notes. // docs:start:insert - self.set.insert(&mut addend_note).emit(encode_and_encrypt_note( - self.context, - outgoing_viewer_keys.ovpk_m, - owner, - sender, - )); + self.set.insert(&mut addend_note).emit(encode_and_encrypt_note(self.context, owner, sender)); // docs:end:insert } // Very similar to `value_note::utils::decrement`. - pub fn sub( - self, - subtrahend: u64, - owner: AztecAddress, - outgoing_viewer: AztecAddress, - sender: AztecAddress, - ) { - let outgoing_viewer_keys = get_public_keys(outgoing_viewer); - + pub fn sub(self, subtrahend: u64, owner: AztecAddress, sender: AztecAddress) { // docs:start:pop_notes let options = NoteGetterOptions::with_filter(filter_notes_min_sum, subtrahend as Field); let notes = self.set.pop_notes(options); @@ -72,11 +52,6 @@ impl EasyPrivateUint<&mut PrivateContext> { // Creates change note for the owner. let result_value = minuend - subtrahend; let mut result_note = ValueNote::new(result_value as Field, owner); - self.set.insert(&mut result_note).emit(encode_and_encrypt_note( - self.context, - outgoing_viewer_keys.ovpk_m, - owner, - sender, - )); + self.set.insert(&mut result_note).emit(encode_and_encrypt_note(self.context, owner, sender)); } } diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index 06eaca64a06..c1ba4aebb22 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -21,20 +21,12 @@ pub fn increment( // docs:start:increment_args balance: PrivateSet, amount: Field, - recipient: AztecAddress, - outgoing_viewer: AztecAddress, // docs:end:increment_args + recipient: AztecAddress, // docs:end:increment_args sender: AztecAddress, ) { - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(amount, recipient); // Insert the new note to the owner's set of notes and emit the log if value is non-zero. - balance.insert(&mut note).emit(encode_and_encrypt_note( - balance.context, - outgoing_viewer_ovpk_m, - recipient, - sender, - )); + balance.insert(&mut note).emit(encode_and_encrypt_note(balance.context, recipient, sender)); } // Find some of the `owner`'s notes whose values add up to the `amount`. @@ -45,10 +37,9 @@ pub fn decrement( balance: PrivateSet, amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, sender: AztecAddress, ) { - let sum = decrement_by_at_most(balance, amount, owner, outgoing_viewer, sender); + let sum = decrement_by_at_most(balance, amount, owner, sender); assert(sum == amount, "Balance too low"); } @@ -64,7 +55,6 @@ pub fn decrement_by_at_most( balance: PrivateSet, max_amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, sender: AztecAddress, ) -> Field { let options = create_note_getter_options_for_decreasing_balance(max_amount); @@ -84,7 +74,7 @@ pub fn decrement_by_at_most( change_value = decremented - max_amount; decremented -= change_value; } - increment(balance, change_value, owner, outgoing_viewer, sender); + increment(balance, change_value, owner, sender); decremented } diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index 168260ebcc2..8428117427a 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -10,7 +10,6 @@ contract AppSubscription { use authwit::auth::assert_current_call_valid_authwit; use aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{initializer, private, public}, storage::storage}, prelude::{AztecAddress, Map, PrivateMutable, PublicImmutable}, protocol_types::constants::MAX_FIELD_VALUE, @@ -43,12 +42,8 @@ contract AppSubscription { note.remaining_txs -= 1; - // We are emitting both the outgoing and the incoming logs to the subscriber here because passing a separate - // outgoing_viewer arg to entrypoint function is impractical and the outgoing are not so valuable here. - let keys = get_public_keys(user_address); storage.subscriptions.at(user_address).replace(&mut note).emit(encode_and_encrypt_note( &mut context, - keys.ovpk_m, user_address, user_address, )); @@ -109,17 +104,10 @@ contract AppSubscription { &mut context, ); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; - let mut subscription_note = SubscriptionNote::new(subscriber, expiry_block_number, tx_count); storage.subscriptions.at(subscriber).initialize_or_replace(&mut subscription_note).emit( - encode_and_encrypt_note( - &mut context, - msg_sender_ovpk_m, - subscriber, - context.msg_sender(), - ), + encode_and_encrypt_note(&mut context, subscriber, context.msg_sender()), ); } diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index e04c1c2ffb9..91c7cdcf32e 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -20,15 +20,9 @@ contract Benchmarking { // Creates a new value note for the target owner. Use this method to seed an initial set of notes. #[private] - fn create_note(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { + fn create_note(owner: AztecAddress, sender: AztecAddress, value: Field) { // docs:start:increment_valuenote - increment( - storage.notes.at(owner), - value, - owner, - outgoing_viewer, - outgoing_viewer, - ); + increment(storage.notes.at(owner), value, owner, sender); // docs:end:increment_valuenote } // Deletes a note at a specific index in the set and creates a new one with the same value. @@ -37,18 +31,12 @@ contract Benchmarking { // See https://discourse.aztec.network/t/utxo-concurrency-issues-for-private-state/635 // by @rahul-kothari for a full explanation on why this is needed. #[private] - fn recreate_note(owner: AztecAddress, outgoing_viewer: AztecAddress, index: u32) { + fn recreate_note(owner: AztecAddress, sender: AztecAddress, index: u32) { let owner_notes = storage.notes.at(owner); let mut getter_options = NoteGetterOptions::new(); let notes = owner_notes.pop_notes(getter_options.set_limit(1).set_offset(index)); let note = notes.get(0); - increment( - owner_notes, - note.value, - owner, - outgoing_viewer, - outgoing_viewer, - ); + increment(owner_notes, note.value, owner, sender); } // Reads and writes to public storage and enqueues a call to another public function. diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index ed1e4257d8f..07d826cbd4f 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -109,14 +109,11 @@ impl Deck { impl Deck<&mut PrivateContext> { pub fn add_cards(&mut self, cards: [Card; N], owner: AztecAddress) -> [CardNote] { - let msg_sender_ovpk_m = get_public_keys(self.set.context.msg_sender()).ovpk_m; - let mut inserted_cards = &[]; for card in cards { let mut card_note = CardNote::from_card(card, owner); self.set.insert(&mut card_note.note).emit(encode_and_encrypt_note( self.set.context, - msg_sender_ovpk_m, owner, self.set.context.msg_sender(), )); diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index 7bde2038e7e..51855c02c1a 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -7,7 +7,6 @@ contract Child { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{internal, private, public}, storage::storage}, note::note_getter_options::NoteGetterOptions, utils::comparison::Comparator, @@ -56,12 +55,9 @@ contract Child { #[private] fn private_set_value(new_value: Field, owner: AztecAddress) -> Field { - let owner_ovpk_m = get_public_keys(owner).ovpk_m; - let mut note = ValueNote::new(new_value, owner); storage.a_map_with_private_values.at(owner).insert(&mut note).emit(encode_and_encrypt_note( &mut context, - owner_ovpk_m, owner, owner, )); diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index 04ef191bc9f..b88cd864158 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -54,6 +54,7 @@ contract ContractInstanceDeployer { // isInfinite: false, // kind: 'point' // } + impl Serialize<15> for ContractInstanceDeployed { fn serialize(self) -> [Field; 15] { [ diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index 04e34bdec90..336d886f31b 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -22,15 +22,15 @@ contract Counter { #[initializer] #[private] // We can name our initializer anything we want as long as it's marked as aztec(initializer) - fn initialize(headstart: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn initialize(headstart: u64, owner: AztecAddress) { let counters = storage.counters; - counters.at(owner).add(headstart, owner, outgoing_viewer, context.msg_sender()); + counters.at(owner).add(headstart, owner, context.msg_sender()); } // docs:end:constructor // docs:start:increment #[private] - fn increment(owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn increment(owner: AztecAddress, sender: AztecAddress) { unsafe { dep::aztec::oracle::debug_log::debug_log_format( "Incrementing counter for owner {0}", @@ -38,7 +38,7 @@ contract Counter { ); } let counters = storage.counters; - counters.at(owner).add(1, owner, outgoing_viewer, outgoing_viewer); + counters.at(owner).add(1, owner, sender); } // docs:end:increment // docs:start:get_counter @@ -52,7 +52,7 @@ contract Counter { use dep::aztec::note::note_getter::{MAX_NOTES_PER_PAGE, view_notes}; use dep::aztec::note::note_viewer_options::NoteViewerOptions; use dep::aztec::protocol_types::storage::map::derive_storage_slot_in_map; - use dep::aztec::test::helpers::{cheatcodes, test_environment::TestEnvironment}; + use dep::aztec::test::helpers::test_environment::TestEnvironment; // docs:end:test_imports // docs:start:txe_test_increment #[test] @@ -60,12 +60,11 @@ contract Counter { // Setup env, generate keys let mut env = TestEnvironment::new(); let owner = env.create_account(); - let outgoing_viewer = env.create_account(); + let sender = env.create_account(); let initial_value: Field = 5; env.impersonate(owner); // Deploy contract and initialize - let initializer = - Counter::interface().initialize(initial_value as u64, owner, outgoing_viewer); + let initializer = Counter::interface().initialize(initial_value as u64, owner); let counter_contract = env.deploy_self("Counter").with_private_initializer(initializer); let contract_address = counter_contract.to_address(); // docs:start:txe_test_read_notes @@ -82,7 +81,7 @@ contract Counter { ); // docs:end:txe_test_read_notes // Increment the counter - Counter::at(contract_address).increment(owner, outgoing_viewer).call(&mut env.private()); + Counter::at(contract_address).increment(owner, sender).call(&mut env.private()); // get_counter is an unconstrained function, so we call it directly (we're in the same module) let current_value_for_owner = get_counter(owner); let expected_current_value = initial_value + 1; diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index 40d738a512c..1042a69519c 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -8,7 +8,6 @@ contract Crowdfunding { // docs:start:all-deps use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{ events::event, functions::{initializer, internal, private, public}, @@ -85,11 +84,9 @@ contract Crowdfunding { // docs:start:valuenote_new let mut note = ValueNote::new(amount as Field, donor); - let donor_ovpk_m = get_public_keys(donor).ovpk_m; // docs:end:valuenote_new storage.donation_receipts.insert(&mut note).emit(encode_and_encrypt_note( &mut context, - donor_ovpk_m, donor, donor, )); diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 2583f21c524..789738091da 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -18,7 +18,6 @@ contract DocsExample { // how to import dependencies defined in your workspace use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{internal, private, public, view}, storage::{storage, storage_no_init}}, }; use dep::aztec::prelude::{ @@ -161,10 +160,8 @@ contract DocsExample { fn initialize_private_immutable(randomness: Field, points: u8) { let mut new_card = CardNote::new(points, randomness, context.msg_sender()); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.private_immutable.initialize(&mut new_card).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); @@ -176,11 +173,9 @@ contract DocsExample { fn initialize_private(randomness: Field, points: u8) { let mut legendary_card = CardNote::new(points, randomness, context.msg_sender()); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; // create and broadcast note storage.legendary_card.initialize(&mut legendary_card).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); @@ -188,13 +183,10 @@ contract DocsExample { #[private] fn insert_notes(amounts: [u8; 3]) { - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; - for i in 0..amounts.len() { let mut note = CardNote::new(amounts[i], 1, context.msg_sender()); storage.set.insert(&mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); @@ -204,10 +196,8 @@ contract DocsExample { fn insert_note(amount: u8, randomness: Field) { let mut note = CardNote::new(amount, randomness, context.msg_sender()); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.set.insert(&mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); @@ -222,10 +212,8 @@ contract DocsExample { fn update_legendary_card(randomness: Field, points: u8) { let mut new_card = CardNote::new(points, randomness, context.msg_sender()); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.legendary_card.replace(&mut new_card).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); @@ -243,11 +231,9 @@ contract DocsExample { let points = card.points + 1; let mut new_card = CardNote::new(points, card.randomness, context.msg_sender()); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; // docs:start:state_vars-PrivateMutableReplace storage.legendary_card.replace(&mut new_card).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, context.msg_sender(), context.msg_sender(), )); diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index 8abf2a3be45..b324d7a6581 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -18,32 +18,27 @@ contract EasyPrivateToken { */ #[private] #[initializer] - fn constructor(initial_supply: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn constructor(initial_supply: u64, owner: AztecAddress) { let balances = storage.balances; - balances.at(owner).add(initial_supply, owner, outgoing_viewer, context.msg_sender()); + balances.at(owner).add(initial_supply, owner, context.msg_sender()); } // Mints `amount` of tokens to `owner`. #[private] - fn mint(amount: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn mint(amount: u64, owner: AztecAddress) { let balances = storage.balances; - balances.at(owner).add(amount, owner, outgoing_viewer, context.msg_sender()); + balances.at(owner).add(amount, owner, context.msg_sender()); } // Transfers `amount` of tokens from `sender` to a `recipient`. #[private] - fn transfer( - amount: u64, - sender: AztecAddress, - recipient: AztecAddress, - outgoing_viewer: AztecAddress, - ) { + fn transfer(amount: u64, sender: AztecAddress, recipient: AztecAddress) { let balances = storage.balances; - balances.at(sender).sub(amount, sender, outgoing_viewer, sender); - balances.at(recipient).add(amount, recipient, outgoing_viewer, sender); + balances.at(sender).sub(amount, sender, sender); + balances.at(recipient).add(amount, recipient, sender); } // Helper function to get the balance of a user ("unconstrained" is a Noir alternative of Solidity's "view" function). diff --git a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr index 5a486330c9b..7d5a9254810 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr @@ -6,7 +6,6 @@ use dep::aztec::macros::aztec; contract EcdsaKAccount { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{initializer, noinitcheck, private, view}, storage::storage}, }; use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; @@ -29,15 +28,10 @@ contract EcdsaKAccount { #[initializer] fn constructor(signing_pub_key_x: [u8; 32], signing_pub_key_y: [u8; 32]) { let this = context.this_address(); - // Not emitting outgoing for msg_sender here to not have to register keys for the contract through which we - // deploy this (typically MultiCallEntrypoint). I think it's ok here as I feel the outgoing here is not that - // important. let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - let this_ovpk_m = get_public_keys(this).ovpk_m; storage.public_key.initialize(&mut pub_key_note).emit(encode_and_encrypt_note( &mut context, - this_ovpk_m, this, this, )); diff --git a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr index 94e86352fda..db99f10a75b 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr @@ -5,7 +5,6 @@ use dep::aztec::macros::aztec; contract EcdsaRAccount { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{initializer, noinitcheck, private, view}, storage::storage}, }; use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; @@ -28,14 +27,9 @@ contract EcdsaRAccount { #[initializer] fn constructor(signing_pub_key_x: [u8; 32], signing_pub_key_y: [u8; 32]) { let this = context.this_address(); - // Not emitting outgoing for msg_sender here to not have to register keys for the contract through which we - // deploy this (typically MultiCallEntrypoint). I think it's ok here as I feel the outgoing here is not that - // important. let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - let this_ovpk_m = get_public_keys(this).ovpk_m; storage.public_key.initialize(&mut pub_key_note).emit(encode_and_encrypt_note( &mut context, - this_ovpk_m, this, this, )); diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index 219e8c8dd55..f5683b01ed0 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -5,7 +5,6 @@ use dep::aztec::macros::aztec; contract Escrow { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{initializer, private}, storage::storage}, }; use dep::aztec::prelude::{AztecAddress, PrivateImmutable}; @@ -27,10 +26,8 @@ contract Escrow { // docs:start:addressnote_new let mut note = AddressNote::new(owner, owner); // docs:end:addressnote_new - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.owner.initialize(&mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, owner, context.msg_sender(), )); diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 65dafc9a93f..8f0a7c2bef5 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -3,10 +3,7 @@ use dep::aztec::macros::aztec; #[aztec] contract InclusionProofs { - use dep::aztec::{ - encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, - }; + use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::aztec::prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable}; use dep::aztec::{ @@ -35,10 +32,8 @@ contract InclusionProofs { fn create_note(owner: AztecAddress, value: Field) { let mut note = ValueNote::new(value, owner); - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.private_values.at(owner).insert(&mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, owner, context.msg_sender(), )); diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index ecec8c4a226..6623284ec81 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -14,7 +14,6 @@ contract NFT { }; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{ events::event, functions::{initializer, internal, private, public, view}, @@ -186,10 +185,7 @@ contract NFT { let note_randomness = unsafe { random() }; let note_setup_payload = NFTNote::setup_payload().new(to, note_randomness, to_note_slot); - // We set the ovpk to the message sender's ovpk and we encrypt the log. - let from_ovpk = get_public_keys(context.msg_sender()).ovpk_m; - let setup_log = - note_setup_payload.encrypt_log(context, from_ovpk, to, context.msg_sender()); + let setup_log = note_setup_payload.encrypt_log(context, to, context.msg_sender()); // Using the x-coordinate as a hiding point slot is safe against someone else interfering with it because // we have a guarantee that the public functions of the transaction are executed right after the private ones @@ -228,7 +224,7 @@ contract NFT { fn _store_payload_in_transient_storage_unsafe( slot: Field, point: Point, - setup_log: [Field; 14], + setup_log: [Field; 9], ) { context.storage_write(slot, point); context.storage_write(slot + aztec::protocol_types::point::POINT_LENGTH as Field, setup_log); @@ -301,15 +297,8 @@ contract NFT { .set_limit(1)); assert(notes.len() == 1, "NFT not found when transferring"); - let from_ovpk_m = get_public_keys(from).ovpk_m; - let mut new_note = NFTNote::new(token_id, to); - nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note( - &mut context, - from_ovpk_m, - to, - from, - )); + nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, to, from)); } #[private] diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index eb3016cfe62..86ad8ea31e9 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -8,7 +8,6 @@ use dep::aztec::macros::aztec; contract PendingNoteHashes { // Libs use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::keys::getters::get_public_keys; use dep::aztec::macros::{functions::private, storage::storage}; use dep::aztec::note::note_emission::NoteEmission; use dep::aztec::prelude::{ @@ -34,21 +33,14 @@ contract PendingNoteHashes { fn test_insert_then_get_then_nullify_flat( amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, ) -> Field { let owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(amount, owner); // Insert note - owner_balance.insert(&mut note).emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + owner_balance.insert(&mut note).emit(encode_and_encrypt_note(&mut context, owner, sender)); let options = NoteGetterOptions::with_filter(filter_notes_min_sum, amount); // get note inserted above @@ -80,79 +72,50 @@ contract PendingNoteHashes { } // Dummy nested/inner function (to pass a function which does nothing) + // QUESTION: can this be removed? I can't `dummy(` being used anywhere in typescript-land. #[private] - fn dummy(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) {} + fn dummy(amount: Field, owner: AztecAddress, sender: AztecAddress) {} // Nested/inner function to create and insert a note #[private] - fn insert_note(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn insert_note(amount: Field, owner: AztecAddress, sender: AztecAddress) { let owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(amount, owner); // Insert note - owner_balance.insert(&mut note).emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + owner_balance.insert(&mut note).emit(encode_and_encrypt_note(&mut context, owner, sender)); } // Nested/inner function to create and insert a note // TESTING: inserts a static randomness value to test notes with // the same note hash are dealt with correctly #[private] - fn insert_note_static_randomness( - amount: Field, - owner: AztecAddress, - outgoing_viewer: AztecAddress, - ) { + fn insert_note_static_randomness(amount: Field, owner: AztecAddress, sender: AztecAddress) { let mut owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(amount, owner); note.randomness = 2; // Insert note - owner_balance.insert(&mut note).emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + owner_balance.insert(&mut note).emit(encode_and_encrypt_note(&mut context, owner, sender)); } // Nested/inner function to create and insert a note // then emit another note log for the same note #[private] - fn insert_note_extra_emit(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn insert_note_extra_emit(amount: Field, owner: AztecAddress, sender: AztecAddress) { let mut owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(amount, owner); // Insert note let emission = owner_balance.insert(&mut note); - emission.emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + emission.emit(encode_and_encrypt_note(&mut context, owner, sender)); // Emit note again - emission.emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + emission.emit(encode_and_encrypt_note(&mut context, owner, sender)); } // Nested/inner function to get a note and confirm it matches the expected value @@ -186,7 +149,7 @@ contract PendingNoteHashes { fn test_insert_then_get_then_nullify_all_in_nested_calls( amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, insert_fn_selector: FunctionSelector, get_then_nullify_fn_selector: FunctionSelector, ) { @@ -194,7 +157,7 @@ contract PendingNoteHashes { let _res = context.call_private_function( inputs.call_context.contract_address, insert_fn_selector, - [amount, owner.to_field(), outgoing_viewer.to_field()], + [amount, owner.to_field(), sender.to_field()], ); // nested call to read and nullify that note let _res = context.call_private_function( @@ -209,12 +172,12 @@ contract PendingNoteHashes { fn test_insert2_then_get2_then_nullify2_all_in_nested_calls( amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, insert_fn_selector: FunctionSelector, get_then_nullify_fn_selector: FunctionSelector, ) { // args for nested calls - let insertArgs = [amount, owner.to_field(), outgoing_viewer.to_field()]; + let insertArgs = [amount, owner.to_field(), sender.to_field()]; let getNullifyArgs = [amount, owner.to_field()]; // nested call to create/insert note @@ -249,12 +212,12 @@ contract PendingNoteHashes { fn test_insert2_then_get2_then_nullify1_all_in_nested_calls( amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, insert_fn_selector: FunctionSelector, get_then_nullify_fn_selector: FunctionSelector, ) { // args for nested calls - let insertArgs = [amount, owner.to_field(), outgoing_viewer.to_field()]; + let insertArgs = [amount, owner.to_field(), sender.to_field()]; let getNullifyArgs = [amount, owner.to_field()]; // nested call to create/insert note @@ -283,12 +246,12 @@ contract PendingNoteHashes { fn test_insert1_then_get2_then_nullify2_all_in_nested_calls( amount: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, insert_fn_selector: FunctionSelector, get_then_nullify_fn_selector: FunctionSelector, ) { // args for nested calls - let insertArgs = [amount, owner.to_field(), outgoing_viewer.to_field()]; + let insertArgs = [amount, owner.to_field(), sender.to_field()]; let getNullifyArgs = [amount, owner.to_field()]; // nested call to create/insert note @@ -327,32 +290,32 @@ contract PendingNoteHashes { #[private] fn test_recursively_create_notes( owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, how_many_recursions: u64, ) { - create_max_notes(owner, outgoing_viewer, storage, &mut context); + create_max_notes(owner, sender, storage, &mut context); PendingNoteHashes::at(context.this_address()) - .recursively_destroy_and_create_notes(owner, outgoing_viewer, how_many_recursions) + .recursively_destroy_and_create_notes(owner, sender, how_many_recursions) .call(&mut context); } #[private] fn recursively_destroy_and_create_notes( owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, executions_left: u64, ) { assert(executions_left > 0); destroy_max_notes(owner, storage); - create_max_notes(owner, outgoing_viewer, storage, &mut context); + create_max_notes(owner, sender, storage, &mut context); let executions_left = executions_left - 1; if executions_left > 0 { PendingNoteHashes::at(context.this_address()) - .recursively_destroy_and_create_notes(owner, outgoing_viewer, executions_left) + .recursively_destroy_and_create_notes(owner, sender, executions_left) .call(&mut context); } } @@ -361,18 +324,15 @@ contract PendingNoteHashes { // by using an existing note's counter via its header. This is used to check that // the pxe rejects the note log later. #[private] - fn test_emit_bad_note_log(owner: AztecAddress, outgoing_viewer: AztecAddress) { + fn test_emit_bad_note_log(owner: AztecAddress, sender: AztecAddress) { let owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut good_note = ValueNote::new(10, owner); // Insert good note with real log owner_balance.insert(&mut good_note).emit(encode_and_encrypt_note( &mut context, - outgoing_viewer_ovpk_m, owner, - outgoing_viewer, + sender, )); // We will emit a note log with an incorrect preimage to ensure the pxe throws @@ -382,33 +342,21 @@ contract PendingNoteHashes { let existing_note_header = good_note.get_header(); bad_note.set_header(existing_note_header); - NoteEmission::new(bad_note).emit(encode_and_encrypt_note( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + NoteEmission::new(bad_note).emit(encode_and_encrypt_note(&mut context, owner, sender)); } #[contract_library_method] fn create_max_notes( owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, storage: Storage<&mut PrivateContext>, context: &mut PrivateContext, ) { let owner_balance = storage.balances.at(owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - for i in 0..max_notes_per_call() { let mut note = ValueNote::new(i as Field, owner); - owner_balance.insert(&mut note).emit(encode_and_encrypt_note( - context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + owner_balance.insert(&mut note).emit(encode_and_encrypt_note(context, owner, sender)); } } diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index b040ba5f1fe..6fea7719fdf 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -13,7 +13,7 @@ contract SchnorrAccount { entrypoint::{app::AppPayload, fee::FeePayload}, }; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::{hash::compute_siloed_nullifier, keys::getters::get_public_keys}; + use dep::aztec::hash::compute_siloed_nullifier; use dep::aztec::macros::{ functions::{initializer, noinitcheck, private, view}, storage::storage, @@ -33,14 +33,9 @@ contract SchnorrAccount { #[initializer] fn constructor(signing_pub_key_x: Field, signing_pub_key_y: Field) { let this = context.this_address(); - // Not emitting outgoing for msg_sender here to not have to register keys for the contract through which we - // deploy this (typically MultiCallEntrypoint). I think it's ok here as I feel the outgoing here is not that - // important. let mut pub_key_note = PublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - let this_ovpk_m = get_public_keys(this).ovpk_m; storage.signing_public_key.initialize(&mut pub_key_note).emit(encode_and_encrypt_note( &mut context, - this_ovpk_m, this, this, )); diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr index 3523cc6e3f7..fc84d76a768 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr @@ -8,7 +8,6 @@ contract Spam { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_unconstrained, - keys::getters::get_public_keys, macros::{functions::{internal, private, public}, storage::storage}, prelude::{AztecAddress, Map, PublicMutable}, protocol_types::{ @@ -31,12 +30,11 @@ contract Spam { #[private] fn spam(nullifier_seed: Field, nullifier_count: u32, call_public: bool) { let caller = context.msg_sender(); - let caller_ovpk_m = get_public_keys(caller).ovpk_m; let amount = U128::from_integer(1); for _ in 0..MAX_NOTE_HASHES_PER_CALL { storage.balances.at(caller).add(caller, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, caller_ovpk_m, caller, caller), + encode_and_encrypt_note_unconstrained(&mut context, caller, caller), ); } diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 99df952a7bc..f8f7fc8d15b 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -18,9 +18,9 @@ contract StatefulTest { #[private] #[initializer] - fn constructor(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { + fn constructor(owner: AztecAddress, sender: AztecAddress, value: Field) { StatefulTest::at(context.this_address()) - .create_note_no_init_check(owner, outgoing_viewer, value) + .create_note_no_init_check(owner, sender, value) .call(&mut context); } @@ -42,19 +42,19 @@ contract StatefulTest { } #[private] - fn create_note(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { + fn create_note(owner: AztecAddress, sender: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); - increment(loc, value, owner, outgoing_viewer, outgoing_viewer); + increment(loc, value, owner, sender); } } #[private] #[noinitcheck] - fn create_note_no_init_check(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { + fn create_note_no_init_check(owner: AztecAddress, sender: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); - increment(loc, value, owner, outgoing_viewer, outgoing_viewer); + increment(loc, value, owner, sender); } } @@ -64,10 +64,10 @@ contract StatefulTest { let sender = context.msg_sender(); let sender_notes = storage.notes.at(sender); - decrement(sender_notes, amount, sender, sender, sender); + decrement(sender_notes, amount, sender, sender); let recipient_notes = storage.notes.at(recipient); - increment(recipient_notes, amount, recipient, sender, sender); + increment(recipient_notes, amount, recipient, sender); } #[private] @@ -76,10 +76,10 @@ contract StatefulTest { let sender = context.msg_sender(); let sender_notes = storage.notes.at(sender); - decrement(sender_notes, amount, sender, sender, sender); + decrement(sender_notes, amount, sender, sender); let recipient_notes = storage.notes.at(recipient); - increment(recipient_notes, amount, recipient, sender, sender); + increment(recipient_notes, amount, recipient, sender); } #[public] diff --git a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr index 26ca21d1d75..3c202a4f918 100644 --- a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr @@ -7,7 +7,6 @@ contract StaticChild { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, macros::{functions::{private, public, view}, storage::storage}, note::note_getter_options::NoteGetterOptions, utils::comparison::Comparator, @@ -46,11 +45,8 @@ contract StaticChild { #[view] fn private_illegal_set_value(new_value: Field, owner: AztecAddress) -> Field { let mut note = ValueNote::new(new_value, owner); - - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; storage.a_private_value.insert(&mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, owner, context.msg_sender(), )); @@ -59,19 +55,13 @@ contract StaticChild { // Modify a note #[private] - fn private_set_value( - new_value: Field, - owner: AztecAddress, - outgoing_viewer: AztecAddress, - ) -> Field { + fn private_set_value(new_value: Field, owner: AztecAddress, sender: AztecAddress) -> Field { let mut note = ValueNote::new(new_value, owner); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; storage.a_private_value.insert(&mut note).emit(encode_and_encrypt_note( &mut context, - outgoing_viewer_ovpk_m, owner, - outgoing_viewer, + sender, )); new_value } diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 30210cbdadb..058b21fc434 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -96,7 +96,7 @@ contract Test { fn call_create_note( value: Field, owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, storage_slot: Field, ) { assert( @@ -104,14 +104,11 @@ contract Test { "this storage slot is reserved for example_constant", ); - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let mut note = ValueNote::new(value, owner); create_note(&mut context, storage_slot, &mut note).emit(encode_and_encrypt_note( &mut context, - outgoing_viewer_ovpk_m, owner, - outgoing_viewer, + sender, )); } @@ -287,11 +284,9 @@ contract Test { fn emit_array_as_encrypted_log( fields: [Field; 5], owner: AztecAddress, - outgoing_viewer: AztecAddress, + sender: AztecAddress, nest: bool, ) { - let outgoing_viewer_ovpk_m = get_public_keys(outgoing_viewer).ovpk_m; - let event = ExampleEvent { value0: fields[0], value1: fields[1], @@ -300,18 +295,13 @@ contract Test { value4: fields[4], }; - event.emit(encode_and_encrypt_event_unconstrained( - &mut context, - outgoing_viewer_ovpk_m, - owner, - outgoing_viewer, - )); + event.emit(encode_and_encrypt_event_unconstrained(&mut context, owner, sender)); // this contract has reached max number of functions, so using this one fn // to test nested and non nested encrypted logs if nest { Test::at(context.this_address()) - .emit_array_as_encrypted_log([0, 0, 0, 0, 0], owner, outgoing_viewer, false) + .emit_array_as_encrypted_log([0, 0, 0, 0, 0], owner, sender, false) .call(&mut context); // Emit a log with non-encrypted content for testing purpose. @@ -321,29 +311,22 @@ contract Test { } #[private] - fn emit_encrypted_logs_nested( - value: Field, - owner: AztecAddress, - outgoing_viewer: AztecAddress, - ) { + fn emit_encrypted_logs_nested(value: Field, owner: AztecAddress, sender: AztecAddress) { let mut storage_slot = storage.example_constant.get_storage_slot() + 1; - Test::at(context.this_address()) - .call_create_note(value, owner, outgoing_viewer, storage_slot) - .call(&mut context); + Test::at(context.this_address()).call_create_note(value, owner, sender, storage_slot).call( + &mut context, + ); storage_slot += 1; - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; - let mut note = ValueNote::new(value + 1, owner); create_note(&mut context, storage_slot, &mut note).emit(encode_and_encrypt_note( &mut context, - msg_sender_ovpk_m, owner, - outgoing_viewer, + sender, )); storage_slot += 1; Test::at(context.this_address()) - .call_create_note(value + 2, owner, outgoing_viewer, storage_slot) + .call_create_note(value + 2, owner, sender, storage_slot) .call(&mut context); } diff --git a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr index fa7c33be0b3..03b30bfa88c 100644 --- a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr @@ -3,7 +3,6 @@ use dep::aztec::macros::aztec; #[aztec] contract TestLog { use dep::aztec::encrypted_logs::encrypted_event_emission::encode_and_encrypt_event; - use dep::aztec::keys::getters::get_public_keys; use dep::aztec::macros::{events::event, functions::{private, public}, storage::storage}; use dep::aztec::prelude::PrivateSet; use dep::aztec::protocol_types::{address::AztecAddress, traits::Serialize}; @@ -32,45 +31,21 @@ contract TestLog { example_set: PrivateSet, } - // EXAMPLE_EVENT_0_BYTES_LEN + 16 - global EXAMPLE_EVENT_0_CIPHERTEXT_BYTES_LEN: Field = 144; - #[private] fn emit_encrypted_events(other: AztecAddress, preimages: [Field; 4]) { let event0 = ExampleEvent0 { value0: preimages[0], value1: preimages[1] }; - let other_ovpk_m = get_public_keys(other).ovpk_m; - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; - - event0.emit(encode_and_encrypt_event( - &mut context, - // outgoing is set to other, incoming is set to msg sender - other_ovpk_m, - context.msg_sender(), - other, - )); + event0.emit(encode_and_encrypt_event(&mut context, context.msg_sender(), other)); - // We duplicate the emission, but specifying different incoming and outgoing parties - event0.emit(encode_and_encrypt_event( - &mut context, - // outgoing is set to msg sender, incoming is set to other - msg_sender_ovpk_m, - other, - context.msg_sender(), - )); + // We duplicate the emission, but swapping the sender and recipient: + event0.emit(encode_and_encrypt_event(&mut context, other, context.msg_sender())); let event1 = ExampleEvent1 { value2: AztecAddress::from_field(preimages[2]), value3: preimages[3] as u8, }; - event1.emit(encode_and_encrypt_event( - &mut context, - // outgoing is set to other, incoming is set to msg sender - other_ovpk_m, - context.msg_sender(), - other, - )); + event1.emit(encode_and_encrypt_event(&mut context, context.msg_sender(), other)); } #[public] diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 4588e7382e7..ec66fd86590 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -16,7 +16,6 @@ contract TokenBlacklist { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_unconstrained, hash::compute_secret_hash, - keys::getters::get_public_keys, macros::{functions::{initializer, internal, private, public, view}, storage::storage}, prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable, SharedMutable}, utils::comparison::Comparator, @@ -187,16 +186,10 @@ contract TokenBlacklist { assert(notes.len() == 1, "note not popped"); // Add the token note to user's balances set - let msg_sender_ovpk_m = get_public_keys(context.msg_sender()).ovpk_m; - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue + // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.add(to, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained( - &mut context, - msg_sender_ovpk_m, - to, - context.msg_sender(), - ), + encode_and_encrypt_note_unconstrained(&mut context, to, context.msg_sender()), ); } @@ -213,11 +206,10 @@ contract TokenBlacklist { assert(nonce == 0, "invalid nonce"); } - let from_ovpk_m = get_public_keys(from).ovpk_m; // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), + encode_and_encrypt_note_unconstrained(&mut context, from, from), ); TokenBlacklist::at(context.this_address())._increase_public_balance(to, amount).enqueue( @@ -239,18 +231,14 @@ contract TokenBlacklist { assert(nonce == 0, "invalid nonce"); } - let from_ovpk_m = get_public_keys(from).ovpk_m; - let amount = U128::from_integer(amount); storage.balances.sub(from, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, from, from, )); storage.balances.add(to, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, to, from, )); @@ -267,11 +255,10 @@ contract TokenBlacklist { assert(nonce == 0, "invalid nonce"); } - let from_ovpk_m = get_public_keys(from).ovpk_m; - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue + // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), + encode_and_encrypt_note_unconstrained(&mut context, from, from), ); TokenBlacklist::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 2d70fde20a1..642244cf251 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -24,7 +24,6 @@ contract Token { encrypted_event_emission::encode_and_encrypt_event_unconstrained, encrypted_note_emission::encode_and_encrypt_note_unconstrained, }, - keys::getters::get_public_keys, macros::{ events::event, functions::{initializer, internal, private, public, view}, @@ -251,11 +250,10 @@ contract Token { assert(nonce == 0, "invalid nonce"); } - let from_ovpk_m = get_public_keys(from).ovpk_m; // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), + encode_and_encrypt_note_unconstrained(&mut context, from, from), ); Token::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context); } @@ -266,8 +264,6 @@ contract Token { fn transfer(to: AztecAddress, amount: Field) { let from = context.msg_sender(); - let from_ovpk_m = get_public_keys(from).ovpk_m; - let amount = U128::from_integer(amount); // We reduce `from`'s balance by amount by recursively removing notes over potentially multiple calls. This // method keeps the gate count for each individual call low - reading too many notes at once could result in @@ -284,13 +280,11 @@ contract Token { ); storage.balances.at(from).add(from, change).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, from, from, )); storage.balances.at(to).add(to, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, to, from, )); @@ -299,7 +293,7 @@ contract Token { // another person where the payment is considered to be successful when the other party successfully decrypts a // note). Transfer { from, to, amount: amount.to_field() }.emit( - encode_and_encrypt_event_unconstrained(&mut context, from_ovpk_m, to, from), + encode_and_encrypt_event_unconstrained(&mut context, to, from), ); } // docs:end:transfer @@ -378,7 +372,6 @@ contract Token { assert(nonce == 0, "invalid nonce"); } // docs:end:assert_current_call_valid_authwit - let from_ovpk_m = get_public_keys(from).ovpk_m; let amount = U128::from_integer(amount); // docs:start:increase_private_balance @@ -387,7 +380,6 @@ contract Token { // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, from, from, )); @@ -397,7 +389,6 @@ contract Token { // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(to).add(to, amount).emit(encode_and_encrypt_note_unconstrained( &mut context, - from_ovpk_m, to, from, )); @@ -412,11 +403,10 @@ contract Token { } else { assert(nonce == 0, "invalid nonce"); } - let from_ovpk_m = get_public_keys(from).ovpk_m; // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from_ovpk_m, from, from), + encode_and_encrypt_note_unconstrained(&mut context, from, from), ); Token::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } @@ -460,7 +450,7 @@ contract Token { /// function. #[contract_library_method] fn _prepare_private_balance_increase( - from: AztecAddress, // recipient of the outgoing: TODO(#9887): this is not great? + from: AztecAddress, // sender of the tag: TODO(#9887): this is not great? to: AztecAddress, context: &mut PrivateContext, storage: Storage<&mut PrivateContext>, @@ -474,8 +464,7 @@ contract Token { let note_setup_payload = UintNote::setup_payload().new(to, note_randomness, to_note_slot); // We get the keys and encrypt the log of the note - let from_ovpk = get_public_keys(from).ovpk_m; - let setup_log = note_setup_payload.encrypt_log(context, from_ovpk, to, from); + let setup_log = note_setup_payload.encrypt_log(context, to, from); // Using the x-coordinate as a hiding point slot is safe against someone else interfering with it because // we have a guarantee that the public functions of the transaction are executed right after the private ones @@ -555,7 +544,7 @@ contract Token { /// in the enqueud call). #[private] fn mint_to_private( - from: AztecAddress, // recipient of the outgoing: TODO(#9887): this is not great? + from: AztecAddress, // sender of the tag: TODO(#9887): this is not great? to: AztecAddress, amount: Field, ) { @@ -655,9 +644,6 @@ contract Token { // the authwit flow here and check that the user really permitted fee_payer to set up a refund on their behalf. assert_current_call_valid_authwit(&mut context, user); - // 2. Since user is the logical sender of all the notes we get user's ovpk and use that in all of them. - let user_ovpk = get_public_keys(user).ovpk_m; - // 3. Deduct the funded amount from the user's balance - this is a maximum fee a user is willing to pay // (called fee limit in aztec spec). The difference between fee limit and the actual tx fee will be refunded // to the user in the `complete_refund(...)` function. @@ -670,14 +656,11 @@ contract Token { ); storage.balances.at(user).add(user, change).emit(encode_and_encrypt_note_unconstrained( &mut context, - user_ovpk, user, user, )); // 4. We prepare the partial notes - // TODO(#9887): In each `_prepare_private_balance_increase` call we fetch the user's ovpk_m 2 more times. This is - // very inefficient. let fee_payer_point_slot = _prepare_private_balance_increase(user, fee_payer, &mut context, storage); let user_point_slot = _prepare_private_balance_increase(user, user, &mut context, storage); @@ -702,7 +685,7 @@ contract Token { fn _store_payload_in_transient_storage_unsafe( slot: Field, point: Point, - setup_log: [Field; 14], + setup_log: [Field; 9], ) { context.storage_write(slot, point); context.storage_write(slot + aztec::protocol_types::point::POINT_LENGTH as Field, setup_log); diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index 98e0d1451ae..e68033ee222 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -6,7 +6,6 @@ import { type IncomingNotesFilter, type L2Block, type LogFilter, - type OutgoingNotesFilter, type PXE, type PXEInfo, type PrivateExecutionResult, @@ -133,9 +132,6 @@ export abstract class BaseWallet implements Wallet { getIncomingNotes(filter: IncomingNotesFilter): Promise { return this.pxe.getIncomingNotes(filter); } - getOutgoingNotes(filter: OutgoingNotesFilter): Promise { - return this.pxe.getOutgoingNotes(filter); - } getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise { return this.pxe.getPublicStorageAt(contract, storageSlot); } @@ -204,7 +200,6 @@ export abstract class BaseWallet implements Wallet { limit: number, vpks: Point[] = [ this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey, - this.getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey, ], ): Promise { return this.pxe.getEncryptedEvents(event, from, limit, vpks); diff --git a/yarn-project/bot/src/bot.ts b/yarn-project/bot/src/bot.ts index 45d6142bb4a..a2ff17876b1 100644 --- a/yarn-project/bot/src/bot.ts +++ b/yarn-project/bot/src/bot.ts @@ -65,7 +65,7 @@ export class Bot { } else { calls.push( ...times(privateTransfersPerTx, () => - token.methods.transfer(TRANSFER_AMOUNT, sender, recipient, sender).request(), + token.methods.transfer(TRANSFER_AMOUNT, sender, recipient).request(), ), ); } diff --git a/yarn-project/bot/src/factory.ts b/yarn-project/bot/src/factory.ts index d41ddf174ff..5d4e3817554 100644 --- a/yarn-project/bot/src/factory.ts +++ b/yarn-project/bot/src/factory.ts @@ -112,7 +112,7 @@ export class BotFactory { if (this.config.contract === SupportedTokenContracts.TokenContract) { deploy = TokenContract.deploy(wallet, wallet.getAddress(), 'BotToken', 'BOT', 18); } else if (this.config.contract === SupportedTokenContracts.EasyPrivateTokenContract) { - deploy = EasyPrivateTokenContract.deploy(wallet, MINT_BALANCE, wallet.getAddress(), wallet.getAddress()); + deploy = EasyPrivateTokenContract.deploy(wallet, MINT_BALANCE, wallet.getAddress()); deployOpts.skipPublicDeployment = true; deployOpts.skipClassRegistration = true; deployOpts.skipInitialization = false; @@ -163,7 +163,7 @@ export class BotFactory { calls.push( isStandardToken ? token.methods.mint_to_private(from, sender, MINT_BALANCE).request() - : token.methods.mint(MINT_BALANCE, sender, sender).request(), + : token.methods.mint(MINT_BALANCE, sender).request(), ); } if (isStandardToken && publicBalance < MIN_BALANCE) { diff --git a/yarn-project/circuit-types/src/interfaces/pxe.test.ts b/yarn-project/circuit-types/src/interfaces/pxe.test.ts index 65976b07ac7..8530f731bd1 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.test.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.test.ts @@ -35,7 +35,7 @@ import { type InBlock } from '../in_block.js'; import { L2Block } from '../l2_block.js'; import { ExtendedUnencryptedL2Log, type GetUnencryptedLogsResponse, type LogFilter } from '../logs/index.js'; import { type IncomingNotesFilter } from '../notes/incoming_notes_filter.js'; -import { ExtendedNote, type OutgoingNotesFilter, UniqueNote } from '../notes/index.js'; +import { ExtendedNote, UniqueNote } from '../notes/index.js'; import { PrivateExecutionResult } from '../private_execution_result.js'; import { type EpochProofQuote } from '../prover_coordination/epoch_proof_quote.js'; import { SiblingPath } from '../sibling_path/sibling_path.js'; @@ -205,11 +205,6 @@ describe('PXESchema', () => { expect(result).toEqual([expect.any(BigInt), expect.any(SiblingPath)]); }); - it('getOutgoingNotes', async () => { - const result = await context.client.getOutgoingNotes({ contractAddress: address }); - expect(result).toEqual([expect.any(UniqueNote)]); - }); - it('addNote', async () => { await context.client.addNote(ExtendedNote.random(), address); }); @@ -442,10 +437,6 @@ class MockPXE implements PXE { expect(secret).toBeInstanceOf(Fr); return Promise.resolve([1n, SiblingPath.random(L1_TO_L2_MSG_TREE_HEIGHT)]); } - getOutgoingNotes(filter: OutgoingNotesFilter): Promise { - expect(filter.contractAddress).toEqual(this.address); - return Promise.resolve([UniqueNote.random()]); - } addNote(note: ExtendedNote, scope?: AztecAddress | undefined): Promise { expect(note).toBeInstanceOf(ExtendedNote); expect(scope).toEqual(this.address); diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 2ed9f7bea75..363511bad80 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -37,7 +37,7 @@ import { LogFilterSchema, } from '../logs/index.js'; import { type IncomingNotesFilter, IncomingNotesFilterSchema } from '../notes/incoming_notes_filter.js'; -import { ExtendedNote, type OutgoingNotesFilter, OutgoingNotesFilterSchema, UniqueNote } from '../notes/index.js'; +import { ExtendedNote, UniqueNote } from '../notes/index.js'; import { PrivateExecutionResult } from '../private_execution_result.js'; import { SiblingPath } from '../sibling_path/sibling_path.js'; import { Tx, TxHash, TxProvingResult, TxReceipt, TxSimulationResult } from '../tx/index.js'; @@ -261,13 +261,6 @@ export interface PXE { secret: Fr, ): Promise<[bigint, SiblingPath]>; - /** - * Gets outgoing notes of accounts registered in this PXE based on the provided filter. - * @param filter - The filter to apply to the notes. - * @returns The requested notes. - */ - getOutgoingNotes(filter: OutgoingNotesFilter): Promise; - /** * Adds a note to the database. * @throws If the note hash of the note doesn't exist in the tree. @@ -424,7 +417,7 @@ export interface PXE { * @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event * @param from - The block number to search from. * @param limit - The amount of blocks to search. - * @param vpks - The viewing (incoming and outgoing) public keys that correspond to the viewing secret keys that can decrypt the log. + * @param vpks - The incoming viewing public keys that can decrypt the log. * @returns - The deserialized events. */ getEncryptedEvents( @@ -435,7 +428,7 @@ export interface PXE { ): Promise; /** - * Returns the unenctypred events given search parameters. + * Returns the unencrypted events given search parameters. * @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event * @param from - The block number to search from. * @param limit - The amount of blocks to search. @@ -523,7 +516,6 @@ export const PXESchema: ApiSchemaFor = { .function() .args(schemas.AztecAddress, schemas.Fr, schemas.Fr) .returns(z.tuple([schemas.BigInt, SiblingPath.schemaFor(L1_TO_L2_MSG_TREE_HEIGHT)])), - getOutgoingNotes: z.function().args(OutgoingNotesFilterSchema).returns(z.array(UniqueNote.schema)), addNote: z.function().args(ExtendedNote.schema, optional(schemas.AztecAddress)).returns(z.void()), addNullifiedNote: z.function().args(ExtendedNote.schema).returns(z.void()), getBlock: z diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts index af663a834ab..6da6d0f200b 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts @@ -2,12 +2,9 @@ import { AztecAddress, CompleteAddress, IndexedTaggingSecret, - KeyValidationRequest, type PrivateLog, computeAddressSecret, - computeOvskApp, deriveKeys, - derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; import { randomBytes } from '@aztec/foundation/crypto'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; @@ -21,7 +18,6 @@ const PLACEHOLDER_TAG = new Fr(33); describe('EncryptedLogPayload', () => { describe('encrypt and decrypt a full log', () => { let completeAddress: CompleteAddress; - let ovskM: GrumpkinScalar; let ivskM: GrumpkinScalar; let original: EncryptedLogPayload; @@ -34,15 +30,13 @@ describe('EncryptedLogPayload', () => { const secretKey = Fr.random(); const partialAddress = Fr.random(); - ({ masterOutgoingViewingSecretKey: ovskM, masterIncomingViewingSecretKey: ivskM } = deriveKeys(secretKey)); + ({ masterIncomingViewingSecretKey: ivskM } = deriveKeys(secretKey)); completeAddress = CompleteAddress.fromSecretKeyAndPartialAddress(secretKey, partialAddress); - const ovKeys = getKeyValidationRequest(ovskM, contract); - const ephSk = GrumpkinScalar.random(); - payload = original.generatePayload(ephSk, completeAddress.address, ovKeys); + payload = original.generatePayload(ephSk, completeAddress.address); }); it('decrypt a log as incoming', () => { @@ -52,53 +46,49 @@ describe('EncryptedLogPayload', () => { expect(recreated?.toBuffer()).toEqual(original.toBuffer()); }); - - it('decrypt a log as outgoing', () => { - const recreated = EncryptedLogPayload.decryptAsOutgoing(payload, ovskM); - - expect(recreated?.toBuffer()).toEqual(original.toBuffer()); - }); }); - it('outgoing cipher text matches Noir', () => { - const ephSk = GrumpkinScalar.fromHighLow( - new Fr(0x000000000000000000000000000000000f096b423017226a18461115fa8d34bbn), - new Fr(0x00000000000000000000000000000000d0d302ee245dfaf2807e604eec4715fen), - ); + // MIKE Q: why is there note an "incoming" version of this test? + // it('outgoing cipher text matches Noir', () => { + // const ephSk = GrumpkinScalar.fromHighLow( + // new Fr(0x000000000000000000000000000000000f096b423017226a18461115fa8d34bbn), + // new Fr(0x00000000000000000000000000000000d0d302ee245dfaf2807e604eec4715fen), + // ); - const senderOvskApp = GrumpkinScalar.fromHighLow( - new Fr(0x00000000000000000000000000000000089c6887cb1446d86c64e81afc78048bn), - new Fr(0x0000000000000000000000000000000074d2e28c6bc5176ac02cf7c7d36a444en), - ); + // const senderOvskApp = GrumpkinScalar.fromHighLow( + // new Fr(0x00000000000000000000000000000000089c6887cb1446d86c64e81afc78048bn), + // new Fr(0x0000000000000000000000000000000074d2e28c6bc5176ac02cf7c7d36a444en), + // ); - const ephPk = derivePublicKeyFromSecretKey(ephSk); + // const ephPk = derivePublicKeyFromSecretKey(ephSk); - const recipient = AztecAddress.fromBigInt(0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70cn); + // const recipient = AztecAddress.fromBigInt(0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70cn); - const addressPoint = recipient.toAddressPoint(); + // const addressPoint = recipient.toAddressPoint(); - const outgoingBodyCiphertext = EncryptedLogPayload.encryptOutgoingBody( - ephSk, - ephPk, - recipient, - addressPoint, - senderOvskApp, - ).toString('hex'); + // const outgoingBodyCiphertext = EncryptedLogPayload.encryptOutgoingBody( + // ephSk, + // ephPk, + // recipient, + // addressPoint, + // senderOvskApp, + // ).toString('hex'); - expect(outgoingBodyCiphertext).toMatchInlineSnapshot( - `"61dd35a8f238d9b8727f89621f3f56b38bc6a2a2d89effcd5ad48d3709f50692ca898124be1f115997cb2bc4cbe9b24fca46fab612bf4f2acdcc910e0d23ff8b8e42c1f0afe9b42599eb2958e834ebd5321a99e319f2a15c2d98646a1dc08365797e1f76bf5aee2b18523112c76b5307"`, - ); + // expect(outgoingBodyCiphertext).toMatchInlineSnapshot( + // `"61dd35a8f238d9b8727f89621f3f56b38bc6a2a2d89effcd5ad48d3709f50692ca898124be1f115997cb2bc4cbe9b24fca46fab612bf4f2acdcc910e0d23ff8b8e42c1f0afe9b42599eb2958e834ebd5321a99e319f2a15c2d98646a1dc08365797e1f76bf5aee2b18523112c76b5307"`, + // ); - const byteArrayString = `[${outgoingBodyCiphertext.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))}]`; + // const byteArrayString = `[${outgoingBodyCiphertext.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))}]`; - // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data - updateInlineTestData( - 'noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr', - 'outgoing_body_ciphertext_from_typescript', - byteArrayString, - ); - }); + // // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data + // updateInlineTestData( + // 'noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr', + // 'outgoing_body_ciphertext_from_typescript', + // byteArrayString, + // ); + // }); + // TODO: why is this using ov keys, and not iv keys? it('encrypted tagged log matches Noir', () => { // All the values in this test were arbitrarily set and copied over to `payload.nr` const contract = AztecAddress.fromString('0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04'); @@ -113,9 +103,6 @@ describe('EncryptedLogPayload', () => { ); const log = new EncryptedLogPayload(logTag, contract, plaintext); - const ovskM = new GrumpkinScalar(0x1d7f6b3c491e99f32aad05c433301f3a2b4ed68de661ff8255d275ff94de6fc4n); - const ovKeys = getKeyValidationRequest(ovskM, contract); - const ephSk = new GrumpkinScalar(0x1358d15019d4639393d62b97e1588c095957ce74a1c32d6ec7d62fe6705d9538n); const recipientCompleteAddress = CompleteAddress.fromString( @@ -127,7 +114,7 @@ describe('EncryptedLogPayload', () => { return Buffer.from(Array(len).fill(1)); }; - const payload = log.generatePayload(ephSk, recipientCompleteAddress.address, ovKeys, fixedRand); + const payload = log.generatePayload(ephSk, recipientCompleteAddress.address, fixedRand); expect(payload.toBuffer().toString('hex')).toMatchInlineSnapshot( `"0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9003de818923f85187871d99bdf95d695eff0a9e09ba15153fc9b4d224b6e1e7100dfbdcaab06c09d5b3c749bfebe1c0407eccd04f51bbb59142680c8a091b97f00c6cbcf615def593ab09e5b3f7f58f6fc235c90e7c77ed8dadb3b05ee4545a700bc612c9139475fee6070be47efcc43a5cbbc873632f1428fac952df9c181db005f9e850b21fe11fedef37b88caee95111bce776e488df219732d0a77d19201007047186f41445ecd5c603487f7fb3c8f31010a22af69ce00000000000000000000000000000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba009dc0cec8c70b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b720095748ad19c1083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd5009b3781c9c02a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b9516200a6e9d067655cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf6002c2f49f549f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e2500881548ec9606a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f8009970aeb3d9489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea1920022fb10df358c765edada497db4284ae30507a2e03e983d23cfa0bd831577e8"`, @@ -147,11 +134,4 @@ describe('EncryptedLogPayload', () => { const recreated = EncryptedLogPayload.decryptAsIncoming(payload, addressSecret); expect(recreated?.toBuffer()).toEqual(log.toBuffer()); }); - - const getKeyValidationRequest = (ovskM: GrumpkinScalar, app: AztecAddress) => { - const ovskApp = computeOvskApp(ovskM, app); - const ovpkM = derivePublicKeyFromSecretKey(ovskM); - - return new KeyValidationRequest(ovpkM, ovskApp); - }; }); diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts index 599d73eb9c5..a5a647e424e 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts @@ -1,41 +1,31 @@ import { AztecAddress, - Fq, Fr, - GrumpkinScalar, - type KeyValidationRequest, + type GrumpkinScalar, NotOnCurveError, PRIVATE_LOG_SIZE_IN_FIELDS, Point, PrivateLog, type PublicKey, - computeOvskApp, derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; import { randomBytes } from '@aztec/foundation/crypto'; import { BufferReader, type Tuple, numToUInt16BE, serializeToBuffer } from '@aztec/foundation/serialize'; import { decrypt, encrypt } from './encryption_util.js'; -import { derivePoseidonAESSecret } from './shared_secret_derivation.js'; // Below constants should match the values defined in aztec-nr/aztec/src/encrypted_logs/payload.nr. -// Both the incoming and the outgoing header are 48 bytes../shared_secret_derivation.js +// The incoming header is 48 bytes../shared_secret_derivation.js // 32 bytes for the address, and 16 bytes padding to follow PKCS#7 const HEADER_SIZE = 48; -// The outgoing body is constant size: -// 96 bytes for the secret key, address and public key, and 16 bytes padding to follow PKCS#7 -const OUTGOING_BODY_SIZE = 112; - // Padding added to the overhead to make the size of the incoming body ciphertext a multiple of 16. const OVERHEAD_PADDING = 15; const OVERHEAD_SIZE = 32 /* eph_pk */ + HEADER_SIZE /* incoming_header */ + - HEADER_SIZE /* outgoing_header */ + - OUTGOING_BODY_SIZE /* outgoing_body */ + OVERHEAD_PADDING; /* padding */ const ENCRYPTED_PAYLOAD_SIZE_IN_BYTES = (PRIVATE_LOG_SIZE_IN_FIELDS - 1) * 31; @@ -60,20 +50,16 @@ class Overhead { constructor( public ephPk: Point, public incomingHeader: Buffer, - public outgoingHeader: Buffer, - public outgoingBody: Buffer, ) {} static fromBuffer(reader: BufferReader) { const ephPk = Point.fromCompressedBuffer(reader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); const incomingHeader = reader.readBytes(HEADER_SIZE); - const outgoingHeader = reader.readBytes(HEADER_SIZE); - const outgoingBody = reader.readBytes(OUTGOING_BODY_SIZE); // Advance the index to skip the padding. reader.readBytes(OVERHEAD_PADDING); - return new Overhead(ephPk, incomingHeader, outgoingHeader, outgoingBody); + return new Overhead(ephPk, incomingHeader); } } @@ -99,35 +85,20 @@ export class EncryptedLogPayload { public generatePayload( ephSk: GrumpkinScalar, recipient: AztecAddress, - ovKeys: KeyValidationRequest, rand: (len: number) => Buffer = randomBytes, ): PrivateLog { const addressPoint = recipient.toAddressPoint(); const ephPk = derivePublicKeyFromSecretKey(ephSk); const incomingHeaderCiphertext = encrypt(this.contractAddress.toBuffer(), ephSk, addressPoint); - const outgoingHeaderCiphertext = encrypt(this.contractAddress.toBuffer(), ephSk, ovKeys.pkM); if (incomingHeaderCiphertext.length !== HEADER_SIZE) { throw new Error(`Invalid incoming header size: ${incomingHeaderCiphertext.length}`); } - if (outgoingHeaderCiphertext.length !== HEADER_SIZE) { - throw new Error(`Invalid outgoing header size: ${outgoingHeaderCiphertext.length}`); - } - - const outgoingBodyCiphertext = EncryptedLogPayload.encryptOutgoingBody( - ephSk, - ephPk, - recipient, - addressPoint, - ovKeys.skAppAsGrumpkinScalar, - ); const overhead = serializeToBuffer( ephPk.toCompressedBuffer(), incomingHeaderCiphertext, - outgoingHeaderCiphertext, - outgoingBodyCiphertext, Buffer.alloc(OVERHEAD_PADDING), ); if (overhead.length !== OVERHEAD_SIZE) { @@ -161,28 +132,10 @@ export class EncryptedLogPayload { return new PrivateLog(logFields); } - public static encryptOutgoingBody( - ephSk: GrumpkinScalar, - ephPk: Point, - recipient: AztecAddress, - addressPoint: Point, - secret: GrumpkinScalar, - ) { - const outgoingBodyPlaintext = serializeToBuffer(ephSk, recipient, addressPoint.toCompressedBuffer()); - const outgoingBodyCiphertext = encrypt(outgoingBodyPlaintext, secret, ephPk, derivePoseidonAESSecret); - if (outgoingBodyCiphertext.length !== OUTGOING_BODY_SIZE) { - throw new Error(`Invalid outgoing body size: ${outgoingBodyCiphertext.length}`); - } - return outgoingBodyCiphertext; - } - /** * Decrypts a ciphertext as an incoming log. * * This is executable by the recipient of the note, and uses the addressSecret to decrypt the payload. - * The outgoing parts of the log are ignored entirely. - * - * Produces the same output as `decryptAsOutgoing`. * * @param payload - The payload for the log * @param addressSecret - The address secret, used to decrypt the logs @@ -242,71 +195,6 @@ export class EncryptedLogPayload { } } - /** - * Decrypts a ciphertext as an outgoing log. - * - * This is executable by the sender of the event, and uses the ovsk to decrypt the payload. - * The outgoing parts are decrypted to retrieve information that allows the sender to - * decrypt the incoming log, and learn about the event contents. - * - * Produces the same output as `decryptAsIncoming`. - * - * @param ciphertext - The ciphertext for the log - * @param ovsk - The outgoing viewing secret key, used to decrypt the logs - * @returns The decrypted log payload - */ - public static decryptAsOutgoing(payload: PrivateLog, ovsk: GrumpkinScalar): EncryptedLogPayload | undefined { - try { - const logFields = payload.fields; - const tag = logFields[0]; - const reader = BufferReader.asReader(fieldsToEncryptedBytes(logFields.slice(1))); - - const overhead = Overhead.fromBuffer(reader); - const { contractAddress, ephSk, recipientAddressPoint } = this.#decryptOverhead(overhead, { ovsk }); - - // Now we decrypt the incoming body using the ephSk and recipientIvpk - const ciphertext = reader.readToEnd(); - const incomingBodyPlaintext = this.#decryptIncomingBody(ciphertext, ephSk, recipientAddressPoint); - - return new EncryptedLogPayload(tag, contractAddress, incomingBodyPlaintext); - } catch (e: any) { - // Following error messages are expected to occur when decryption fails - if (!this.isAcceptableError(e)) { - // If we encounter an unexpected error, we rethrow it - throw e; - } - return; - } - } - - /** - * Similar to `decryptAsOutgoing`. Except that this is for the payload coming from public, which has tightly packed - * bytes that don't have 0 byte at the beginning of every 32 bytes. - * And the incoming body is of variable size. - */ - public static decryptAsOutgoingFromPublic(payload: Buffer, ovsk: GrumpkinScalar): EncryptedLogPayload | undefined { - try { - const reader = BufferReader.asReader(payload); - const tag = reader.readObject(Fr); - - const overhead = Overhead.fromBuffer(reader); - const { contractAddress, ephSk, recipientAddressPoint } = this.#decryptOverhead(overhead, { ovsk }); - - // Now we decrypt the incoming body using the ephSk and recipientIvpk - const ciphertext = reader.readToEnd(); - const incomingBodyPlaintext = this.#decryptIncomingBody(ciphertext, ephSk, recipientAddressPoint); - - return new EncryptedLogPayload(tag, contractAddress, incomingBodyPlaintext); - } catch (e: any) { - // Following error messages are expected to occur when decryption fails - if (!this.isAcceptableError(e)) { - // If we encounter an unexpected error, we rethrow it - throw e; - } - return; - } - } - private static isAcceptableError(e: any) { return ( e instanceof NotOnCurveError || @@ -324,7 +212,7 @@ export class EncryptedLogPayload { static #decryptOverhead( overhead: Overhead, - { addressSecret, ovsk }: { addressSecret?: GrumpkinScalar; ovsk?: GrumpkinScalar }, + { addressSecret }: { addressSecret: GrumpkinScalar }, ) { let contractAddress = AztecAddress.ZERO; @@ -333,26 +221,8 @@ export class EncryptedLogPayload { contractAddress = AztecAddress.fromBuffer(incomingHeader); } - let ephSk = GrumpkinScalar.ZERO; - let recipientAddressPoint = Point.ZERO; - if (ovsk) { - const outgoingHeader = decrypt(overhead.outgoingHeader, ovsk, overhead.ephPk); - contractAddress = AztecAddress.fromBuffer(outgoingHeader!); - - const ovskApp = computeOvskApp(ovsk, contractAddress); - const outgoingBody = decrypt(overhead.outgoingBody, ovskApp, overhead.ephPk, derivePoseidonAESSecret); - - // From outgoing body we extract ephSk, recipient and recipientAddressPoint - const obReader = BufferReader.asReader(outgoingBody); - ephSk = obReader.readObject(Fq); - const _recipient = obReader.readObject(AztecAddress); - recipientAddressPoint = Point.fromCompressedBuffer(obReader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); - } - return { contractAddress, - ephSk, - recipientAddressPoint, }; } diff --git a/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.ts index 364b5836fd5..b573027a594 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/l1_event_payload.ts @@ -58,18 +58,6 @@ export class L1EventPayload { ); } - static decryptAsOutgoing(log: PrivateLog, sk: Fq): L1EventPayload | undefined { - const decryptedLog = EncryptedLogPayload.decryptAsOutgoing(log, sk); - if (!decryptedLog) { - return undefined; - } - - return this.#fromIncomingBodyPlaintextAndContractAddress( - decryptedLog.incomingBodyPlaintext, - decryptedLog.contractAddress, - ); - } - /** * Serializes the L1EventPayload object into a Buffer. * @returns Buffer representation of the L1EventPayload object. diff --git a/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts index 7d1d1633efe..70b8628ecfd 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts @@ -90,37 +90,6 @@ export class L1NotePayload { ); } - static decryptAsOutgoing(log: PrivateLog, sk: Fq): L1NotePayload | undefined { - const decryptedLog = EncryptedLogPayload.decryptAsOutgoing(log, sk); - if (!decryptedLog) { - return undefined; - } - - return this.fromIncomingBodyPlaintextContractAndPublicValues( - decryptedLog.incomingBodyPlaintext, - decryptedLog.contractAddress, - /* publicValues */ [], - ); - } - - static decryptAsOutgoingFromPublic(log: Buffer, sk: Fq): L1NotePayload | undefined { - const { privateValues, publicValues } = parseLogFromPublic(log); - if (!privateValues) { - return undefined; - } - - const decryptedLog = EncryptedLogPayload.decryptAsOutgoingFromPublic(privateValues, sk); - if (!decryptedLog) { - return undefined; - } - - return this.fromIncomingBodyPlaintextContractAndPublicValues( - decryptedLog.incomingBodyPlaintext, - decryptedLog.contractAddress, - publicValues, - ); - } - /** * Serializes the L1NotePayload object into a Buffer. * @returns Buffer representation of the L1NotePayload object. diff --git a/yarn-project/circuit-types/src/logs/l1_payload/shared_secret_derivation.ts b/yarn-project/circuit-types/src/logs/l1_payload/shared_secret_derivation.ts index e9e3ea5caff..f6714cfda09 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/shared_secret_derivation.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/shared_secret_derivation.ts @@ -1,6 +1,6 @@ import { GeneratorIndex, type GrumpkinScalar, type PublicKey } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; -import { poseidon2HashWithSeparator, sha256 } from '@aztec/foundation/crypto'; +import { sha256 } from '@aztec/foundation/crypto'; import { numToUInt8 } from '@aztec/foundation/serialize'; /** @@ -28,21 +28,3 @@ export function deriveDiffieHellmanAESSecret(secretKey: GrumpkinScalar, publicKe const hash = sha256(secretBuffer); return hash; } - -/** - * Derives an AES symmetric key from the app siloed outgoing viewing secret key - * and the ephemeral public key using poseidon. - * - * @param ovskApp - The app siloed outgoing viewing secret key - * @param ephPk - The ephemeral public key - * @returns The derived AES symmetric key - */ -export function derivePoseidonAESSecret(ovskApp: GrumpkinScalar, ephPk: PublicKey) { - // For performance reasons, we do NOT use the usual `deriveAESSecret` function here and instead we compute it using - // poseidon. Note that we can afford to use poseidon here instead of deriving shared secret using Diffie-Hellman - // because for outgoing we are encrypting for ourselves and hence we don't need to perform a key exchange. - return poseidon2HashWithSeparator( - [ovskApp.hi, ovskApp.lo, ephPk.x, ephPk.y], - GeneratorIndex.SYMMETRIC_KEY, - ).toBuffer(); -} diff --git a/yarn-project/circuit-types/src/notes/index.ts b/yarn-project/circuit-types/src/notes/index.ts index 30e8b36f510..d926d03e99a 100644 --- a/yarn-project/circuit-types/src/notes/index.ts +++ b/yarn-project/circuit-types/src/notes/index.ts @@ -2,4 +2,3 @@ export * from './comparator.js'; export * from './extended_note.js'; export * from './incoming_notes_filter.js'; export * from './note_status.js'; -export * from './outgoing_notes_filter.js'; diff --git a/yarn-project/circuit-types/src/notes/outgoing_notes_filter.ts b/yarn-project/circuit-types/src/notes/outgoing_notes_filter.ts deleted file mode 100644 index 79f1ae2d488..00000000000 --- a/yarn-project/circuit-types/src/notes/outgoing_notes_filter.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { type AztecAddress, type Fr } from '@aztec/circuits.js'; -import { type ZodFor, schemas } from '@aztec/foundation/schemas'; - -import { z } from 'zod'; - -import { TxHash } from '../tx/tx_hash.js'; - -/** - * A filter used to fetch outgoing notes. - * @remarks This filter is applied as an intersection of all its params. - */ -export type OutgoingNotesFilter = { - /** Hash of a transaction from which to fetch the notes. */ - txHash?: TxHash; - /** The contract address the note belongs to. */ - contractAddress?: AztecAddress; - /** The specific storage location of the note on the contract. */ - storageSlot?: Fr; - /** The owner of the note (whose public key was used to encrypt the note). */ - owner?: AztecAddress; -}; - -export const OutgoingNotesFilterSchema: ZodFor = z.object({ - txHash: TxHash.schema.optional(), - contractAddress: schemas.AztecAddress.optional(), - storageSlot: schemas.Fr.optional(), - owner: schemas.AztecAddress.optional(), -}); diff --git a/yarn-project/cli/src/cmds/devnet/bootstrap_network.ts b/yarn-project/cli/src/cmds/devnet/bootstrap_network.ts index 12b283cbdfd..40d1fcb9e5e 100644 --- a/yarn-project/cli/src/cmds/devnet/bootstrap_network.ts +++ b/yarn-project/cli/src/cmds/devnet/bootstrap_network.ts @@ -232,7 +232,7 @@ async function deployCounter(wallet: Wallet): Promise { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - Importing noir-contracts.js even in devDeps results in a circular dependency error. Need to ignore because this line doesn't cause an error in a dev environment const { CounterContract } = await import('@aztec/noir-contracts.js'); - const counter = await CounterContract.deploy(wallet, 1, wallet.getAddress(), wallet.getAddress()) + const counter = await CounterContract.deploy(wallet, 1, wallet.getAddress()) .send({ universalDeploy: true }) .deployed(waitOpts); const info: ContractDeploymentInfo = { diff --git a/yarn-project/end-to-end/src/benchmarks/utils.ts b/yarn-project/end-to-end/src/benchmarks/utils.ts index 4d2a78bdaad..5dbebfa26ce 100644 --- a/yarn-project/end-to-end/src/benchmarks/utils.ts +++ b/yarn-project/end-to-end/src/benchmarks/utils.ts @@ -58,10 +58,9 @@ export function getFolderSize(path: string): number { */ export function makeCall(index: number, context: EndToEndContext, contract: BenchmarkingContract) { const owner = context.wallet.getAddress(); - // Setting the outgoing viewer to owner here since the outgoing logs are not important in this context - const outgoingViewer = owner; + const sender = owner; return new BatchCall(context.wallet, [ - contract.methods.create_note(owner, outgoingViewer, index + 1).request(), + contract.methods.create_note(owner, sender, index + 1).request(), contract.methods.increment_balance(owner, index + 1).request(), ]); } diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index d3dded0788d..f2f22f0373a 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -248,21 +248,16 @@ describe('e2e_2_pxes', () => { let note: ExtendedNote; { const owner = walletA.getAddress(); - const outgoingViewer = owner; + const sender = owner; const receipt = await testContract.methods - .call_create_note(noteValue, owner, outgoingViewer, noteStorageSlot) + .call_create_note(noteValue, owner, sender, noteStorageSlot) .send() .wait(); await testContract.methods.sync_notes().simulate(); const incomingNotes = await walletA.getIncomingNotes({ txHash: receipt.txHash }); - const outgoingNotes = await walletA.getOutgoingNotes({ txHash: receipt.txHash }); expect(incomingNotes).toHaveLength(1); note = incomingNotes[0]; - - // Since owner is the same as outgoing viewer the incoming and outgoing notes should be the same - expect(outgoingNotes).toHaveLength(1); - expect(outgoingNotes[0]).toEqual(note); } // 3. Nullify the note diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 4989a66d0a9..e3e02121149 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -63,11 +63,11 @@ describe('e2e_block_building', () => { const deployer = new ContractDeployer(artifact, owner); const ownerAddress = owner.getCompleteAddress().address; - const outgoingViewer = ownerAddress; + const sender = ownerAddress; // Need to have value > 0, so adding + 1 // We need to do so, because noir currently will fail if the multiscalarmul is in an `if` // that we DO NOT enter. This should be fixed by https://github.com/noir-lang/noir/issues/5045. - const methods = times(TX_COUNT, i => deployer.deploy(ownerAddress, outgoingViewer, i + 1)); + const methods = times(TX_COUNT, i => deployer.deploy(ownerAddress, sender, i + 1)); const provenTxs = []; for (let i = 0; i < TX_COUNT; i++) { provenTxs.push( @@ -291,10 +291,10 @@ describe('e2e_block_building', () => { const account = getSchnorrAccount(pxe, privateKey, keys.masterIncomingViewingSecretKey); await account.deploy().wait(); const thisWallet = await account.getWallet(); - const outgoingViewer = thisWallet.getAddress(); + const sender = thisWallet.getAddress(); // call test contract - const action = testContract.methods.emit_encrypted_logs_nested(10, thisWallet.getAddress(), outgoingViewer); + const action = testContract.methods.emit_encrypted_logs_nested(10, thisWallet.getAddress(), sender); const tx = await action.prove(); const rct = await tx.send().wait(); @@ -317,7 +317,7 @@ describe('e2e_block_building', () => { const account = getSchnorrAccount(pxe, privateKey, keys.masterIncomingViewingSecretKey); await account.deploy().wait(); const thisWallet = await account.getWallet(); - const outgoingViewer = thisWallet.getAddress(); + const sender = thisWallet.getAddress(); // call test contract const values = [new Fr(5), new Fr(4), new Fr(3), new Fr(2), new Fr(1)]; @@ -325,7 +325,7 @@ describe('e2e_block_building', () => { const action = testContract.methods.emit_array_as_encrypted_log( values, thisWallet.getAddress(), - outgoingViewer, + sender, true, ); const tx = await action.prove(); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts index d436c38e0ac..ea6a112f449 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts @@ -302,8 +302,8 @@ describe('e2e_deploy_contract contract class registration', () => { describe('error scenarios in deployment', () => { it('app logic call to an undeployed contract reverts, but can be included', async () => { const whom = wallet.getAddress(); - const outgoingViewer = whom; - const instance = await t.registerContract(wallet, StatefulTestContract, { initArgs: [whom, outgoingViewer, 42] }); + const sender = whom; + const instance = await t.registerContract(wallet, StatefulTestContract, { initArgs: [whom, sender, 42] }); // Confirm that the tx reverts with the expected message await expect(instance.methods.increment_public_value_no_init_check(whom, 10).send().wait()).rejects.toThrow( /No bytecode/, diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index cebc961785b..c3e2249c1cd 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -59,20 +59,18 @@ describe('e2e_deploy_contract deploy method', () => { .deployed(); expect(await contract.methods.get_public_value(owner).simulate()).toEqual(42n); logger.debug(`Calling a private function to ensure the contract was properly initialized`); - const outgoingViewer = owner; - await contract.methods.create_note(owner, outgoingViewer, 30).send().wait(); + const sender = owner; + await contract.methods.create_note(owner, sender, 30).send().wait(); expect(await contract.methods.summed_values(owner).simulate()).toEqual(30n); }); it('deploys a contract with a default initializer not named constructor', async () => { logger.debug(`Deploying contract with a default initializer named initialize`); const opts = { skipClassRegistration: true, skipPublicDeployment: true }; - // Emitting the outgoing logs to the same address as owner to avoid having to set up another account. - const contract = await CounterContract.deploy(wallet, 10, wallet.getAddress(), wallet.getAddress()) + const contract = await CounterContract.deploy(wallet, 10, wallet.getAddress()) .send(opts) .deployed(); logger.debug(`Calling a function to ensure the contract was properly initialized`); - // Emitting the outgoing logs to the same address as owner to avoid having to set up another account. await contract.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(); expect(await contract.methods.get_counter(wallet.getAddress()).simulate()).toEqual(11n); }); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts index ca7dff265c2..17c5d3b17e9 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts @@ -37,8 +37,8 @@ describe('e2e_deploy_contract private initialization', () => { async kind => { const testWallet = kind === 'as entrypoint' ? new SignerlessWallet(pxe) : wallet; const owner = await t.registerRandomAccount(); - const outgoingViewer = owner; - const initArgs: StatefulContractCtorArgs = [owner, outgoingViewer, 42]; + const sender = owner; + const initArgs: StatefulContractCtorArgs = [owner, sender, 42]; const contract = await t.registerContract(testWallet, StatefulTestContract, { initArgs }); logger.info(`Calling the constructor for ${contract.address}`); await contract.methods @@ -48,7 +48,7 @@ describe('e2e_deploy_contract private initialization', () => { logger.info(`Checking if the constructor was run for ${contract.address}`); expect(await contract.methods.summed_values(owner).simulate()).toEqual(42n); logger.info(`Calling a private function that requires initialization on ${contract.address}`); - await contract.methods.create_note(owner, outgoingViewer, 10).send().wait(); + await contract.methods.create_note(owner, sender, 10).send().wait(); expect(await contract.methods.summed_values(owner).simulate()).toEqual(52n); }, ); @@ -70,10 +70,10 @@ describe('e2e_deploy_contract private initialization', () => { const owner = await t.registerRandomAccount(); const initArgs: StatefulContractCtorArgs = [owner, owner, 42]; const contract = await t.registerContract(wallet, StatefulTestContract, { initArgs }); - const outgoingViewer = owner; + const sender = owner; const batch = new BatchCall(wallet, [ contract.methods.constructor(...initArgs).request(), - contract.methods.create_note(owner, outgoingViewer, 10).request(), + contract.methods.create_note(owner, sender, 10).request(), ]); logger.info(`Executing constructor and private function in batch at ${contract.address}`); await batch.send().wait(); @@ -101,29 +101,29 @@ describe('e2e_deploy_contract private initialization', () => { const initArgs: StatefulContractCtorArgs = [owner, owner, 42]; const contract = await t.registerContract(wallet, StatefulTestContract, { initArgs }); // TODO(@spalladino): It'd be nicer to be able to fail the assert with a more descriptive message. - const outgoingViewer = owner; - await expect(contract.methods.create_note(owner, outgoingViewer, 10).send().wait()).rejects.toThrow( + const sender = owner; + await expect(contract.methods.create_note(owner, sender, 10).send().wait()).rejects.toThrow( /Cannot find the leaf for nullifier/i, ); }); it('refuses to initialize a contract with incorrect args', async () => { const owner = await t.registerRandomAccount(); - const outgoingViewer = owner; - const contract = await t.registerContract(wallet, StatefulTestContract, { initArgs: [owner, outgoingViewer, 42] }); - await expect(contract.methods.constructor(owner, outgoingViewer, 43).prove()).rejects.toThrow( + const sender = owner; + const contract = await t.registerContract(wallet, StatefulTestContract, { initArgs: [owner, sender, 42] }); + await expect(contract.methods.constructor(owner, sender, 43).prove()).rejects.toThrow( /Initialization hash does not match/, ); }); it('refuses to initialize an instance from a different deployer', async () => { const owner = await t.registerRandomAccount(); - const outgoingViewer = owner; + const sender = owner; const contract = await t.registerContract(wallet, StatefulTestContract, { - initArgs: [owner, outgoingViewer, 42], + initArgs: [owner, sender, 42], deployer: owner, }); - await expect(contract.methods.constructor(owner, outgoingViewer, 42).prove()).rejects.toThrow( + await expect(contract.methods.constructor(owner, sender, 42).prove()).rejects.toThrow( /Initializer address is not the contract deployer/i, ); }); diff --git a/yarn-project/end-to-end/src/e2e_event_logs.test.ts b/yarn-project/end-to-end/src/e2e_event_logs.test.ts index bfecaead50e..65901a86972 100644 --- a/yarn-project/end-to-end/src/e2e_event_logs.test.ts +++ b/yarn-project/end-to-end/src/e2e_event_logs.test.ts @@ -96,7 +96,7 @@ describe('Logs', () => { const lastBlockNumber = Math.max(...txs.map(tx => tx.blockNumber!)); const numBlocks = lastBlockNumber - firstBlockNumber + 1; - // We get all the events we can decrypt with either our incoming or outgoing viewing keys + // We get all the events we can decrypt with our incoming viewing keys const collectedEvent0s = await wallets[0].getEncryptedEvents( TestLogContract.events.ExampleEvent0, @@ -112,13 +112,6 @@ describe('Logs', () => { [wallets[0].getCompleteAddress().publicKeys.masterIncomingViewingPublicKey], ); - const collectedEvent0sWithOutgoing = await wallets[0].getEncryptedEvents( - TestLogContract.events.ExampleEvent0, - firstBlockNumber, - numBlocks, - [wallets[0].getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey], - ); - const collectedEvent1s = await wallets[0].getEncryptedEvents( TestLogContract.events.ExampleEvent1, firstBlockNumber, @@ -127,18 +120,17 @@ describe('Logs', () => { ); expect(collectedEvent0sWithIncoming.length).toBe(5); - expect(collectedEvent0sWithOutgoing.length).toBe(5); expect(collectedEvent0s.length).toBe(10); expect(collectedEvent1s.length).toBe(5); - const emptyEvent1s = await wallets[0].getEncryptedEvents( - TestLogContract.events.ExampleEvent1, - firstBlockNumber, - numBlocks, - [wallets[0].getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey], - ); + // const emptyEvent1s = await wallets[0].getEncryptedEvents( + // TestLogContract.events.ExampleEvent1, + // firstBlockNumber, + // numBlocks, + // [wallets[0].getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey], + // ); - expect(emptyEvent1s.length).toBe(0); + // expect(emptyEvent1s.length).toBe(0); const exampleEvent0Sort = (a: ExampleEvent0, b: ExampleEvent0) => (a.value0 > b.value0 ? 1 : -1); expect(collectedEvent0sWithIncoming.sort(exampleEvent0Sort)).toStrictEqual( @@ -147,16 +139,6 @@ describe('Logs', () => { .sort(exampleEvent0Sort), ); - expect(collectedEvent0sWithOutgoing.sort(exampleEvent0Sort)).toStrictEqual( - preimages - .map(preimage => ({ value0: preimage[0].toBigInt(), value1: preimage[1].toBigInt() })) - .sort(exampleEvent0Sort), - ); - - expect([...collectedEvent0sWithIncoming, ...collectedEvent0sWithOutgoing].sort(exampleEvent0Sort)).toStrictEqual( - collectedEvent0s.sort(exampleEvent0Sort), - ); - const exampleEvent1Sort = (a: ExampleEvent1, b: ExampleEvent1) => (a.value2 > b.value2 ? 1 : -1); expect(collectedEvent1s.sort(exampleEvent1Sort)).toStrictEqual( preimages diff --git a/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts b/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts index b9384823a14..45665cfc883 100644 --- a/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts @@ -174,7 +174,6 @@ describe('e2e_fees dapp_subscription', () => { const dappInterface = DefaultDappInterface.createFromUserWallet(aliceWallet, subscriptionContract.address); const counterContractViaDappEntrypoint = counterContract.withWallet(new AccountWallet(pxe, dappInterface)); - // Emitting the outgoing logs to Alice below const { transactionFee } = await counterContractViaDappEntrypoint.methods .increment(bobAddress, aliceAddress) .send() diff --git a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts index 87699648c19..90f29398ad2 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts @@ -299,9 +299,7 @@ export class FeesTest { await this.snapshotManager.snapshot( 'setup_subscription', async () => { - // Deploy counter contract for testing with Bob as owner - // Emitting the outgoing logs to Bob below since we need someone to emit them to. - const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress, this.bobAddress) + const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress) .send() .deployed(); diff --git a/yarn-project/end-to-end/src/e2e_keys.test.ts b/yarn-project/end-to-end/src/e2e_keys.test.ts index b8962a0d203..7cab699963e 100644 --- a/yarn-project/end-to-end/src/e2e_keys.test.ts +++ b/yarn-project/end-to-end/src/e2e_keys.test.ts @@ -71,10 +71,10 @@ describe('Keys', () => { const noteValue = 5; const noteOwner = account.getAddress(); - const outgoingViewer = noteOwner; // Setting the outgoing viewer to owner to not have to bother with setting up another account. + const sender = noteOwner; const noteStorageSlot = 12; - await testContract.methods.call_create_note(noteValue, noteOwner, outgoingViewer, noteStorageSlot).send().wait(); + await testContract.methods.call_create_note(noteValue, noteOwner, sender, noteStorageSlot).send().wait(); expect(await getNumNullifiedNotes(nskApp, testContract.address)).toEqual(0); diff --git a/yarn-project/end-to-end/src/e2e_note_getter.test.ts b/yarn-project/end-to-end/src/e2e_note_getter.test.ts index 31000962d1e..e7aea9067a0 100644 --- a/yarn-project/end-to-end/src/e2e_note_getter.test.ts +++ b/yarn-project/end-to-end/src/e2e_note_getter.test.ts @@ -151,13 +151,12 @@ describe('e2e_note_getter', () => { describe('status filter', () => { let contract: TestContract; let owner: AztecAddress; - let outgoingViewer: AztecAddress; + let sender: AztecAddress; beforeAll(async () => { contract = await TestContract.deploy(wallet).send().deployed(); owner = wallet.getCompleteAddress().address; - // Setting the outgoing viewer to owner not have to bother with setting up another account. - outgoingViewer = owner; + sender = owner; }); const VALUE = 5; @@ -190,12 +189,12 @@ describe('e2e_note_getter', () => { const activeOrNullified = false; it('returns active notes', async () => { - await contract.methods.call_create_note(VALUE, owner, outgoingViewer, storageSlot).send().wait(); + await contract.methods.call_create_note(VALUE, owner, sender, storageSlot).send().wait(); await assertNoteIsReturned(storageSlot, VALUE, activeOrNullified); }); it('does not return nullified notes', async () => { - await contract.methods.call_create_note(VALUE, owner, outgoingViewer, storageSlot).send().wait(); + await contract.methods.call_create_note(VALUE, owner, sender, storageSlot).send().wait(); await contract.methods.call_destroy_note(storageSlot).send().wait(); await assertNoReturnValue(storageSlot, activeOrNullified); @@ -206,12 +205,12 @@ describe('e2e_note_getter', () => { const activeOrNullified = true; it('returns active notes', async () => { - await contract.methods.call_create_note(VALUE, owner, outgoingViewer, storageSlot).send().wait(); + await contract.methods.call_create_note(VALUE, owner, sender, storageSlot).send().wait(); await assertNoteIsReturned(storageSlot, VALUE, activeOrNullified); }); it('returns nullified notes', async () => { - await contract.methods.call_create_note(VALUE, owner, outgoingViewer, storageSlot).send().wait(); + await contract.methods.call_create_note(VALUE, owner, sender, storageSlot).send().wait(); await contract.methods.call_destroy_note(storageSlot).send().wait(); await assertNoteIsReturned(storageSlot, VALUE, activeOrNullified); @@ -220,9 +219,9 @@ describe('e2e_note_getter', () => { it('returns both active and nullified notes', async () => { // We store two notes with two different values in the same storage slot, and then delete one of them. Note that // we can't be sure which one was deleted since we're just deleting based on the storage slot. - await contract.methods.call_create_note(VALUE, owner, outgoingViewer, storageSlot).send().wait(); + await contract.methods.call_create_note(VALUE, owner, sender, storageSlot).send().wait(); await contract.methods - .call_create_note(VALUE + 1, owner, outgoingViewer, storageSlot) + .call_create_note(VALUE + 1, owner, sender, storageSlot) .send() .wait(); await contract.methods.call_destroy_note(storageSlot).send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index a2f6022d7ff..b546e5a4fec 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -76,9 +76,9 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods - .test_insert_then_get_then_nullify_flat(mintAmount, owner, outgoingViewer) + .test_insert_then_get_then_nullify_flat(mintAmount, owner, sender) .send() .wait(); }); @@ -90,12 +90,12 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods .test_insert_then_get_then_nullify_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -115,12 +115,12 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods .test_insert_then_get_then_nullify_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note_extra_emit.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -139,12 +139,12 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods .test_insert2_then_get2_then_nullify2_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -164,12 +164,12 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods .test_insert2_then_get2_then_nullify1_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -189,12 +189,12 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; await deployedContract.methods .test_insert2_then_get2_then_nullify1_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note_static_randomness.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -217,8 +217,8 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); // create persistent note - const outgoingViewer = owner; - await deployedContract.methods.insert_note(mintAmount, owner, outgoingViewer).send().wait(); + const sender = owner; + await deployedContract.methods.insert_note(mintAmount, owner, sender).send().wait(); await expectNoteHashesSquashedExcept(1); // first TX just creates 1 persistent note await expectNullifiersSquashedExcept(0); @@ -229,7 +229,7 @@ describe('e2e_pending_note_hashes_contract', () => { .test_insert1_then_get2_then_nullify2_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.insert_note.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -255,8 +255,8 @@ describe('e2e_pending_note_hashes_contract', () => { const mintAmount = 65n; const deployedContract = await deployContract(); - const outgoingViewer = owner; - await deployedContract.methods.insert_note(mintAmount, owner, outgoingViewer).send().wait(); + const sender = owner; + await deployedContract.methods.insert_note(mintAmount, owner, sender).send().wait(); // There is a single new note hash. await expectNoteHashesSquashedExcept(1); @@ -266,7 +266,7 @@ describe('e2e_pending_note_hashes_contract', () => { .test_insert_then_get_then_nullify_all_in_nested_calls( mintAmount, owner, - outgoingViewer, + sender, deployedContract.methods.dummy.selector, deployedContract.methods.get_then_nullify_note.selector, ) @@ -278,23 +278,22 @@ describe('e2e_pending_note_hashes_contract', () => { }); it('Should handle overflowing the kernel data structures in nested calls', async () => { - // Setting the outgoing viewer to owner not have to bother with setting up another account. - const outgoingViewer = owner; + const sender = owner; const notesPerIteration = Math.min(MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL); const minToNeedReset = Math.min(MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX) + 1; const deployedContract = await deployContract(); await deployedContract.methods - .test_recursively_create_notes(owner, outgoingViewer, Math.ceil(minToNeedReset / notesPerIteration)) + .test_recursively_create_notes(owner, sender, Math.ceil(minToNeedReset / notesPerIteration)) .send() .wait(); }); it('Should drop note log for non existent note', async () => { const deployedContract = await deployContract(); - const outgoingViewer = owner; + const sender = owner; // Add a note of value 10, with a note log // Then emit another note log with the same counter as the one above, but with value 5 - const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, outgoingViewer).send().wait(); + const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, sender).send().wait(); await deployedContract.methods.sync_notes().simulate(); diff --git a/yarn-project/end-to-end/src/e2e_static_calls.test.ts b/yarn-project/end-to-end/src/e2e_static_calls.test.ts index 6b12ab3cd37..1d670377c1a 100644 --- a/yarn-project/end-to-end/src/e2e_static_calls.test.ts +++ b/yarn-project/end-to-end/src/e2e_static_calls.test.ts @@ -10,17 +10,16 @@ describe('e2e_static_calls', () => { let childContract: StaticChildContract; let teardown: () => Promise; let owner: AztecAddress; - let outgoingViewer: AztecAddress; + let sender: AztecAddress; beforeAll(async () => { ({ teardown, wallet } = await setup()); owner = wallet.getCompleteAddress().address; - // Setting the outgoing viewer to owner not have to bother with setting up another account. - (outgoingViewer = owner), (parentContract = await StaticParentContract.deploy(wallet).send().deployed()); + (sender = owner), (parentContract = await StaticParentContract.deploy(wallet).send().deployed()); childContract = await StaticChildContract.deploy(wallet).send().deployed(); // We create a note in the set, such that later reads doesn't fail due to get_notes returning 0 notes - await childContract.methods.private_set_value(42n, owner, outgoingViewer).send().wait(); + await childContract.methods.private_set_value(42n, owner, sender).send().wait(); }); afterAll(() => teardown()); @@ -115,7 +114,7 @@ describe('e2e_static_calls', () => { .private_static_call_3_args(childContract.address, childContract.methods.private_set_value.selector, [ 42n, owner, - outgoingViewer, + sender, ]) .send() .wait(), @@ -137,7 +136,7 @@ describe('e2e_static_calls', () => { .private_nested_static_call_3_args(childContract.address, childContract.methods.private_set_value.selector, [ 42n, owner, - outgoingViewer, + sender, ]) .send() .wait(), diff --git a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts index 31fcb352394..b436499297e 100644 --- a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts +++ b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts @@ -47,7 +47,6 @@ describe(`deploys and transfers a private only token`, () => { deployerWallet, initialBalance, deployerWallet.getAddress(), - deployerWallet.getAddress(), ) .send({ universalDeploy: true, @@ -61,7 +60,7 @@ describe(`deploys and transfers a private only token`, () => { logger.info(`Performing transfer.`); await token.methods - .transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()) + .transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress()) .send() .wait({ timeout: 300 }); diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index bdb6b26336d..ef9d7e290bf 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -3,7 +3,6 @@ import { type IncomingNotesFilter, MerkleTreeId, NoteStatus, - type OutgoingNotesFilter, } from '@aztec/circuit-types'; import { AztecAddress, @@ -28,7 +27,6 @@ import { import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/types/abi'; import { IncomingNoteDao } from './incoming_note_dao.js'; -import { OutgoingNoteDao } from './outgoing_note_dao.js'; import { type PxeDatabase } from './pxe_database.js'; /** @@ -57,12 +55,6 @@ export class KVPxeDatabase implements PxeDatabase { #contractInstances: AztecMap; #db: AztecKVStore; - #outgoingNotes: AztecMap; - #outgoingNotesByContract: AztecMultiMap; - #outgoingNotesByStorageSlot: AztecMultiMap; - #outgoingNotesByTxHash: AztecMultiMap; - #outgoingNotesByOvpkM: AztecMultiMap; - #scopes: AztecSet; #notesToScope: AztecMultiMap; #notesByContractAndScope: Map>; @@ -105,12 +97,6 @@ export class KVPxeDatabase implements PxeDatabase { this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point'); this.#nullifiedNotesByNullifier = db.openMap('nullified_notes_by_nullifier'); - this.#outgoingNotes = db.openMap('outgoing_notes'); - this.#outgoingNotesByContract = db.openMultiMap('outgoing_notes_by_contract'); - this.#outgoingNotesByStorageSlot = db.openMultiMap('outgoing_notes_by_storage_slot'); - this.#outgoingNotesByTxHash = db.openMultiMap('outgoing_notes_by_tx_hash'); - this.#outgoingNotesByOvpkM = db.openMultiMap('outgoing_notes_by_ovpk_m'); - this.#scopes = db.openSet('scopes'); this.#notesToScope = db.openMultiMap('notes_to_scope'); this.#notesByContractAndScope = new Map>(); @@ -201,12 +187,11 @@ export class KVPxeDatabase implements PxeDatabase { } async addNote(note: IncomingNoteDao, scope?: AztecAddress): Promise { - await this.addNotes([note], [], scope); + await this.addNotes([note], scope); } async addNotes( incomingNotes: IncomingNoteDao[], - outgoingNotes: OutgoingNoteDao[], scope: AztecAddress = AztecAddress.ZERO, ): Promise { if (!this.#scopes.has(scope.toString())) { @@ -229,15 +214,6 @@ export class KVPxeDatabase implements PxeDatabase { void this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex); void this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex); } - - for (const dao of outgoingNotes) { - const noteIndex = toBufferBE(dao.index, 32).toString('hex'); - void this.#outgoingNotes.set(noteIndex, dao.toBuffer()); - void this.#outgoingNotesByContract.set(dao.contractAddress.toString(), noteIndex); - void this.#outgoingNotesByStorageSlot.set(dao.storageSlot.toString(), noteIndex); - void this.#outgoingNotesByTxHash.set(dao.txHash.toString(), noteIndex); - void this.#outgoingNotesByOvpkM.set(dao.ovpkM.toString(), noteIndex); - } }); } @@ -258,18 +234,6 @@ export class KVPxeDatabase implements PxeDatabase { } } } - - for (const note of this.#outgoingNotes.values()) { - const noteDao = OutgoingNoteDao.fromBuffer(note); - if (noteDao.l2BlockNumber > blockNumber) { - const noteIndex = toBufferBE(noteDao.index, 32).toString('hex'); - void this.#outgoingNotes.delete(noteIndex); - void this.#outgoingNotesByContract.deleteValue(noteDao.contractAddress.toString(), noteIndex); - void this.#outgoingNotesByStorageSlot.deleteValue(noteDao.storageSlot.toString(), noteIndex); - void this.#outgoingNotesByTxHash.deleteValue(noteDao.txHash.toString(), noteIndex); - void this.#outgoingNotesByOvpkM.deleteValue(noteDao.ovpkM.toString(), noteIndex); - } - } }); } @@ -411,56 +375,6 @@ export class KVPxeDatabase implements PxeDatabase { return Promise.resolve(result); } - getOutgoingNotes(filter: OutgoingNotesFilter): Promise { - const ovpkM: PublicKey | undefined = filter.owner - ? this.#getCompleteAddress(filter.owner)?.publicKeys.masterOutgoingViewingPublicKey - : undefined; - - // Check if ovpkM is truthy - const ids = ovpkM - ? this.#outgoingNotesByOvpkM.getValues(ovpkM.toString()) - : // If ovpkM is falsy, check if filter.txHash is truthy - filter.txHash - ? this.#outgoingNotesByTxHash.getValues(filter.txHash.toString()) - : // If both ovpkM and filter.txHash are falsy, check if filter.contractAddress is truthy - filter.contractAddress - ? this.#outgoingNotesByContract.getValues(filter.contractAddress.toString()) - : // If ovpkM, filter.txHash, and filter.contractAddress are all falsy, check if filter.storageSlot is truthy - filter.storageSlot - ? this.#outgoingNotesByStorageSlot.getValues(filter.storageSlot.toString()) - : // If none of the above conditions are met, retrieve all keys from this.#outgoingNotes - this.#outgoingNotes.keys(); - - const notes: OutgoingNoteDao[] = []; - for (const id of ids) { - const serializedNote = this.#outgoingNotes.get(id); - if (!serializedNote) { - continue; - } - - const note = OutgoingNoteDao.fromBuffer(serializedNote); - if (filter.contractAddress && !note.contractAddress.equals(filter.contractAddress)) { - continue; - } - - if (filter.txHash && !note.txHash.equals(filter.txHash)) { - continue; - } - - if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) { - continue; - } - - if (ovpkM && !note.ovpkM.equals(ovpkM)) { - continue; - } - - notes.push(note); - } - - return Promise.resolve(notes); - } - removeNullifiedNotes(nullifiers: InBlock[], accountAddressPoint: PublicKey): Promise { if (nullifiers.length === 0) { return Promise.resolve([]); @@ -653,10 +567,6 @@ export class KVPxeDatabase implements PxeDatabase { (sum, note) => sum + note.getSize(), 0, ); - const outgoingNotesSize = Array.from(await this.getOutgoingNotes({})).reduce( - (sum, note) => sum + note.getSize(), - 0, - ); const authWitsSize = Array.from(this.#authWitnesses.values()).reduce( (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES, @@ -665,7 +575,7 @@ export class KVPxeDatabase implements PxeDatabase { const addressesSize = this.#completeAddresses.length * CompleteAddress.SIZE_IN_BYTES; const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES; - return incomingNotesSize + outgoingNotesSize + treeRootsSize + authWitsSize + addressesSize; + return incomingNotesSize + treeRootsSize + authWitsSize + addressesSize; } async setTaggingSecretsIndexesAsSender(indexedSecrets: IndexedTaggingSecret[]): Promise { diff --git a/yarn-project/pxe/src/database/pxe_database.ts b/yarn-project/pxe/src/database/pxe_database.ts index a0dfa1ac89a..31ac502aa47 100644 --- a/yarn-project/pxe/src/database/pxe_database.ts +++ b/yarn-project/pxe/src/database/pxe_database.ts @@ -1,4 +1,4 @@ -import { type InBlock, type IncomingNotesFilter, type OutgoingNotesFilter } from '@aztec/circuit-types'; +import { type InBlock, type IncomingNotesFilter } from '@aztec/circuit-types'; import { type BlockHeader, type CompleteAddress, @@ -13,7 +13,6 @@ import { type Fr } from '@aztec/foundation/fields'; import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js'; import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js'; import { type IncomingNoteDao } from './incoming_note_dao.js'; -import { type OutgoingNoteDao } from './outgoing_note_dao.js'; /** * A database interface that provides methods for retrieving, adding, and removing transactional data related to Aztec @@ -57,12 +56,6 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD */ getIncomingNotes(filter: IncomingNotesFilter): Promise; - /** - * Gets outgoing notes. - * @returns The outgoing notes. - */ - getOutgoingNotes(filter: OutgoingNotesFilter): Promise; - /** * Adds a note to DB. * @param note - The note to add. @@ -83,11 +76,10 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD * which can improve performance when dealing with large numbers of transactions. * * @param incomingNotes - An array of notes which were decrypted as incoming. - * @param outgoingNotes - An array of notes which were decrypted as outgoing. * @param scope - The scope to add the notes under. Currently optional. * @remark - Will create a database for the scope if it does not already exist. */ - addNotes(incomingNotes: IncomingNoteDao[], outgoingNotes: OutgoingNoteDao[], scope?: AztecAddress): Promise; + addNotes(incomingNotes: IncomingNoteDao[], scope?: AztecAddress): Promise; /** * Remove nullified notes associated with the given account and nullifiers. diff --git a/yarn-project/pxe/src/database/pxe_database_test_suite.ts b/yarn-project/pxe/src/database/pxe_database_test_suite.ts index 9947e952c51..3b91901b83d 100644 --- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts +++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts @@ -1,4 +1,4 @@ -import { type IncomingNotesFilter, NoteStatus, type OutgoingNotesFilter, randomTxHash } from '@aztec/circuit-types'; +import { type IncomingNotesFilter, NoteStatus, randomTxHash } from '@aztec/circuit-types'; import { AztecAddress, CompleteAddress, @@ -14,7 +14,6 @@ import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmark import { TestContractArtifact } from '@aztec/noir-contracts.js/Test'; import { IncomingNoteDao } from './incoming_note_dao.js'; -import { OutgoingNoteDao } from './outgoing_note_dao.js'; import { type PxeDatabase } from './pxe_database.js'; /** @@ -135,7 +134,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => { - await database.addNotes(notes, []); + await database.addNotes(notes); const returnedNotes = await database.getIncomingNotes(getFilter()); expect(returnedNotes.sort()).toEqual(getExpected().sort()); @@ -152,7 +151,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); it.each(filteringTests)('retrieves nullified notes', async (getFilter, getExpected) => { - await database.addNotes(notes, []); + await database.addNotes(notes); // Nullify all notes and use the same filter as other test cases for (const owner of owners) { @@ -173,7 +172,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); it('skips nullified notes by default or when requesting active', async () => { - await database.addNotes(notes, []); + await database.addNotes(notes); const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint())); const nullifiers = notesToNullify.map(note => ({ @@ -194,7 +193,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { it('handles note unnullification', async () => { await database.setHeader(makeHeader(randomInt(1000), 100, 0 /** slot number */)); - await database.addNotes(notes, []); + await database.addNotes(notes); const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint())); const nullifiers = notesToNullify.map(note => ({ @@ -213,7 +212,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); it('returns active and nullified notes when requesting either', async () => { - await database.addNotes(notes, []); + await database.addNotes(notes); const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint())); const nullifiers = notesToNullify.map(note => ({ @@ -303,7 +302,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); it('removes notes after a given block', async () => { - await database.addNotes(notes, [], owners[0].address); + await database.addNotes(notes, owners[0].address); await database.removeNotesAfter(5); const result = await database.getIncomingNotes({ scopes: [owners[0].address] }); @@ -311,70 +310,6 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { }); }); - describe('outgoing notes', () => { - let owners: CompleteAddress[]; - let contractAddresses: AztecAddress[]; - let storageSlots: Fr[]; - let notes: OutgoingNoteDao[]; - - const filteringTests: [() => OutgoingNotesFilter, () => OutgoingNoteDao[]][] = [ - [() => ({}), () => notes], - - [ - () => ({ contractAddress: contractAddresses[0] }), - () => notes.filter(note => note.contractAddress.equals(contractAddresses[0])), - ], - [() => ({ contractAddress: AztecAddress.random() }), () => []], - - [ - () => ({ storageSlot: storageSlots[0] }), - () => notes.filter(note => note.storageSlot.equals(storageSlots[0])), - ], - [() => ({ storageSlot: Fr.random() }), () => []], - - [() => ({ txHash: notes[0].txHash }), () => [notes[0]]], - [() => ({ txHash: randomTxHash() }), () => []], - - [ - () => ({ owner: owners[0].address }), - () => notes.filter(note => note.ovpkM.equals(owners[0].publicKeys.masterOutgoingViewingPublicKey)), - ], - - [ - () => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[0] }), - () => - notes.filter( - note => note.contractAddress.equals(contractAddresses[0]) && note.storageSlot.equals(storageSlots[0]), - ), - ], - [() => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[1] }), () => []], - ]; - - beforeEach(async () => { - owners = Array.from({ length: 2 }).map(() => CompleteAddress.random()); - contractAddresses = Array.from({ length: 2 }).map(() => AztecAddress.random()); - storageSlots = Array.from({ length: 2 }).map(() => Fr.random()); - - notes = Array.from({ length: 10 }).map((_, i) => - OutgoingNoteDao.random({ - contractAddress: contractAddresses[i % contractAddresses.length], - storageSlot: storageSlots[i % storageSlots.length], - ovpkM: owners[i % owners.length].publicKeys.masterOutgoingViewingPublicKey, - index: BigInt(i), - }), - ); - - for (const owner of owners) { - await database.addCompleteAddress(owner); - } - }); - - it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => { - await database.addNotes([], notes); - await expect(database.getOutgoingNotes(getFilter())).resolves.toEqual(getExpected()); - }); - }); - describe('block header', () => { it('stores and retrieves the block header', async () => { const header = makeHeader(randomInt(1000), INITIAL_L2_BLOCK_NUM, 0 /** slot number */); diff --git a/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts index fc3e1918ce1..6d4fe005ee7 100644 --- a/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts +++ b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts @@ -4,7 +4,6 @@ import { type Logger } from '@aztec/foundation/log'; import { type AcirSimulator } from '@aztec/simulator'; import { IncomingNoteDao } from '../database/incoming_note_dao.js'; -import { OutgoingNoteDao } from '../database/outgoing_note_dao.js'; import { type PxeDatabase } from '../database/pxe_database.js'; import { produceNoteDaosForKey } from './produce_note_daos_for_key.js'; @@ -17,7 +16,6 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js'; * @param simulator - An instance of AcirSimulator. * @param db - An instance of PxeDatabase. * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs. - * @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs. * @param payload - An instance of l1NotePayload. * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction. * @param noteHashes - New note hashes in this transaction, one of which belongs to this note. @@ -25,13 +23,12 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js'; * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate. * @param logger - An instance of Logger. * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes). - * @returns An object containing the incoming, outgoing, and deferred notes. + * @returns An object containing the incoming notes. */ export async function produceNoteDaos( simulator: AcirSimulator, db: PxeDatabase, addressPoint: PublicKey | undefined, - ovpkM: PublicKey | undefined, payload: L1NotePayload, txHash: TxHash, l2BlockNumber: number, @@ -40,16 +37,12 @@ export async function produceNoteDaos( dataStartIndexForTx: number, excludedIndices: Set, logger: Logger, -): Promise<{ - incomingNote: IncomingNoteDao | undefined; - outgoingNote: OutgoingNoteDao | undefined; -}> { - if (!addressPoint && !ovpkM) { - throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.'); +): Promise<{incomingNote: IncomingNoteDao | undefined}> { + if (!addressPoint) { + throw new Error('addressPoint is undefined. Cannot create note.'); } let incomingNote: IncomingNoteDao | undefined; - let outgoingNote: OutgoingNoteDao | undefined; if (addressPoint) { incomingNote = await produceNoteDaosForKey( @@ -68,43 +61,7 @@ export async function produceNoteDaos( ); } - if (ovpkM) { - if (incomingNote) { - // Incoming note is defined meaning that this PXE has both the incoming and outgoing keys. We can skip computing - // note hash and note index since we already have them in the incoming note. - outgoingNote = new OutgoingNoteDao( - incomingNote.note, - incomingNote.contractAddress, - incomingNote.storageSlot, - incomingNote.noteTypeId, - incomingNote.txHash, - incomingNote.l2BlockNumber, - incomingNote.l2BlockHash, - incomingNote.nonce, - incomingNote.noteHash, - incomingNote.index, - ovpkM, - ); - } else { - outgoingNote = await produceNoteDaosForKey( - simulator, - db, - ovpkM, - payload, - txHash, - l2BlockNumber, - l2BlockHash, - noteHashes, - dataStartIndexForTx, - excludedIndices, - logger, - OutgoingNoteDao.fromPayloadAndNoteInfo, - ); - } - } - return { incomingNote, - outgoingNote, }; } diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index eadab26de2d..59ef8854642 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -12,7 +12,6 @@ import { type L2Block, type LogFilter, MerkleTreeId, - type OutgoingNotesFilter, type PXE, type PXEInfo, type PrivateExecutionResult, @@ -320,33 +319,6 @@ export class PXEService implements PXE { return Promise.all(extendedNotes); } - public async getOutgoingNotes(filter: OutgoingNotesFilter): Promise { - const noteDaos = await this.db.getOutgoingNotes(filter); - - const extendedNotes = noteDaos.map(async dao => { - let owner = filter.owner; - if (owner === undefined) { - const completeAddresses = (await this.db.getCompleteAddresses()).find(address => - address.publicKeys.masterOutgoingViewingPublicKey.equals(dao.ovpkM), - ); - if (completeAddresses === undefined) { - throw new Error(`Cannot find complete address for OvpkM ${dao.ovpkM.toString()}`); - } - owner = completeAddresses.address; - } - return new UniqueNote( - dao.note, - owner, - dao.contractAddress, - dao.storageSlot, - dao.noteTypeId, - dao.txHash, - dao.nonce, - ); - }); - return Promise.all(extendedNotes); - } - public async getL1ToL2MembershipWitness( contractAddress: AztecAddress, messageHash: Fr, @@ -936,7 +908,7 @@ export class PXEService implements PXE { for (const sk of vsks) { // TODO: Verify that the first field of the log is the tag siloed with contract address. // Or use tags to query logs, like we do with notes. - const decryptedEvent = L1EventPayload.decryptAsIncoming(log, sk) ?? L1EventPayload.decryptAsOutgoing(log, sk); + const decryptedEvent = L1EventPayload.decryptAsIncoming(log, sk); if (decryptedEvent !== undefined) { return [decryptedEvent]; } diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 802fe6c4214..40c9b37a3a9 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -28,7 +28,6 @@ import { } from '@aztec/circuits.js'; import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi'; import { poseidon2Hash } from '@aztec/foundation/crypto'; -import { tryJsonStringify } from '@aztec/foundation/json-rpc'; import { createDebugLogger } from '@aztec/foundation/log'; import { type KeyStore } from '@aztec/key-store'; import { type AcirSimulator, type DBOracle, MessageLoadOracleInputs } from '@aztec/simulator'; @@ -36,7 +35,6 @@ import { type AcirSimulator, type DBOracle, MessageLoadOracleInputs } from '@azt import { type ContractDataOracle } from '../contract_data_oracle/index.js'; import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; import { type PxeDatabase } from '../database/index.js'; -import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js'; import { produceNoteDaos } from '../note_decryption_utils/produce_note_daos.js'; import { getAcirSimulator } from '../simulator/index.js'; @@ -401,7 +399,7 @@ export class SimulatorOracle implements DBOracle { } /** - * Synchronizes the logs tagged with scoped addresses and all the senders in the addressbook. + * Synchronizes the logs tagged with scoped addresses and all the senders in the address book. * Returns the unsynched logs and updates the indexes of the secrets used to tag them until there are no more logs to sync. * @param contractAddress - The address of the contract that the logs are tagged for * @param recipient - The address of the recipient @@ -427,7 +425,7 @@ export class SimulatorOracle implements DBOracle { const appTaggingSecrets = await this.#getAppTaggingSecretsForContacts(contractAddress, recipient); // 1.1 Set up a sliding window with an offset. Chances are the sender might have messed up - // and inadvertedly incremented their index without use getting any logs (for example, in case + // and inadvertently incremented their index without use getting any logs (for example, in case // of a revert). If we stopped looking for logs the first time // we receive 0 for a tag, we might never receive anything from that sender again. // Also there's a possibility that we have advanced our index, but the sender has reused it, so @@ -538,14 +536,11 @@ export class SimulatorOracle implements DBOracle { recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey, ); const addressSecret = computeAddressSecret(recipientCompleteAddress.getPreaddress(), ivskM); - const ovskM = await this.keyStore.getMasterSecretKey( - recipientCompleteAddress.publicKeys.masterOutgoingViewingPublicKey, - ); + // Since we could have notes with the same index for different txs, we need // to keep track of them scoping by txHash const excludedIndices: Map> = new Map(); const incomingNotes: IncomingNoteDao[] = []; - const outgoingNotes: OutgoingNoteDao[] = []; const txEffectsCache = new Map | undefined>(); @@ -553,21 +548,10 @@ export class SimulatorOracle implements DBOracle { const incomingNotePayload = scopedLog.isFromPublic ? L1NotePayload.decryptAsIncomingFromPublic(scopedLog.logData, addressSecret) : L1NotePayload.decryptAsIncoming(PrivateLog.fromBuffer(scopedLog.logData), addressSecret); - const outgoingNotePayload = scopedLog.isFromPublic - ? L1NotePayload.decryptAsOutgoingFromPublic(scopedLog.logData, ovskM) - : L1NotePayload.decryptAsOutgoing(PrivateLog.fromBuffer(scopedLog.logData), ovskM); - - if (incomingNotePayload || outgoingNotePayload) { - if (incomingNotePayload && outgoingNotePayload && !incomingNotePayload.equals(outgoingNotePayload)) { - this.log.warn( - `Incoming and outgoing note payloads do not match. Incoming: ${tryJsonStringify( - incomingNotePayload, - )}, Outgoing: ${tryJsonStringify(outgoingNotePayload)}`, - ); - continue; - } - const payload = incomingNotePayload || outgoingNotePayload; + if (incomingNotePayload) { + + const payload = incomingNotePayload; const txEffect = txEffectsCache.get(scopedLog.txHash.toString()) ?? (await this.aztecNode.getTxEffect(scopedLog.txHash)); @@ -582,14 +566,13 @@ export class SimulatorOracle implements DBOracle { if (!excludedIndices.has(scopedLog.txHash.toString())) { excludedIndices.set(scopedLog.txHash.toString(), new Set()); } - const { incomingNote, outgoingNote } = await produceNoteDaos( + const { incomingNote } = await produceNoteDaos( // I don't like this at all, but we need a simulator to run `computeNoteHashAndOptionallyANullifier`. This generates // a chicken-and-egg problem due to this oracle requiring a simulator, which in turn requires this oracle. Furthermore, since jest doesn't allow // mocking ESM exports, we have to pollute the method even more by providing a simulator parameter so tests can inject a fake one. simulator ?? getAcirSimulator(this.db, this.aztecNode, this.keyStore, this.contractDataOracle), this.db, incomingNotePayload ? recipient.toAddressPoint() : undefined, - outgoingNotePayload ? recipientCompleteAddress.publicKeys.masterOutgoingViewingPublicKey : undefined, payload!, txEffect.data.txHash, txEffect.l2BlockNumber, @@ -603,12 +586,9 @@ export class SimulatorOracle implements DBOracle { if (incomingNote) { incomingNotes.push(incomingNote); } - if (outgoingNote) { - outgoingNotes.push(outgoingNote); - } } } - return { incomingNotes, outgoingNotes }; + return { incomingNotes }; } /** @@ -621,9 +601,9 @@ export class SimulatorOracle implements DBOracle { recipient: AztecAddress, simulator?: AcirSimulator, ): Promise { - const { incomingNotes, outgoingNotes } = await this.#decryptTaggedLogs(logs, recipient, simulator); - if (incomingNotes.length || outgoingNotes.length) { - await this.db.addNotes(incomingNotes, outgoingNotes, recipient); + const { incomingNotes } = await this.#decryptTaggedLogs(logs, recipient, simulator); + if (incomingNotes.length) { + await this.db.addNotes(incomingNotes, recipient); incomingNotes.forEach(noteDao => { this.log.verbose( `Added incoming note for contract ${noteDao.contractAddress} at slot ${ @@ -631,9 +611,6 @@ export class SimulatorOracle implements DBOracle { } with nullifier ${noteDao.siloedNullifier.toString()}`, ); }); - outgoingNotes.forEach(noteDao => { - this.log.verbose(`Added outgoing note for contract ${noteDao.contractAddress} at slot ${noteDao.storageSlot}`); - }); } const nullifiedNotes: IncomingNoteDao[] = []; const currentNotesForRecipient = await this.db.getIncomingNotes({ owner: recipient }); diff --git a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts index a9804de5eec..9694b562bc5 100644 --- a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts +++ b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts @@ -16,10 +16,8 @@ import { GrumpkinScalar, INITIAL_L2_BLOCK_NUM, IndexedTaggingSecret, - KeyValidationRequest, MAX_NOTE_HASHES_PER_TX, computeAddress, - computeOvskApp, computeTaggingSecret, deriveKeys, } from '@aztec/circuits.js'; @@ -35,7 +33,6 @@ import times from 'lodash.times'; import { type IncomingNoteDao } from '../database/incoming_note_dao.js'; import { type PxeDatabase } from '../database/index.js'; import { KVPxeDatabase } from '../database/kv_pxe_database.js'; -import { type OutgoingNoteDao } from '../database/outgoing_note_dao.js'; import { ContractDataOracle } from '../index.js'; import { SimulatorOracle } from './index.js'; @@ -61,8 +58,6 @@ class MockNoteRequest { public readonly noteHashIndex: number, /** Address point we use when encrypting a note. */ public readonly recipient: AztecAddress, - /** ovKeys we use when encrypting a note. */ - public readonly ovKeys: KeyValidationRequest, ) { if (blockNumber < INITIAL_L2_BLOCK_NUM) { throw new Error(`Block number should be greater than or equal to ${INITIAL_L2_BLOCK_NUM}.`); @@ -77,7 +72,7 @@ class MockNoteRequest { encrypt(): Buffer { const ephSk = GrumpkinScalar.random(); - const log = this.logPayload.generatePayload(ephSk, this.recipient, this.ovKeys); + const log = this.logPayload.generatePayload(ephSk, this.recipient); return log.toBuffer(); } @@ -122,7 +117,6 @@ describe('Simulator oracle', () => { let keyStore: KeyStore; let recipient: CompleteAddress; - let recipientOvKeys: KeyValidationRequest; let contractAddress: AztecAddress; beforeEach(async () => { @@ -137,9 +131,7 @@ describe('Simulator oracle', () => { contractAddress = AztecAddress.random(); // Set up recipient account recipient = await keyStore.addAccount(new Fr(69), Fr.random()); - const recipientOvskApp = await keyStore.getAppOutgoingViewingSecretKey(recipient.address, contractAddress); await database.addCompleteAddress(recipient); - recipientOvKeys = new KeyValidationRequest(recipient.publicKeys.masterOutgoingViewingPublicKey, recipientOvskApp); }); describe('sync tagged logs', () => { @@ -161,7 +153,6 @@ describe('Simulator oracle', () => { 1, 1, recipient.address, - recipientOvKeys, ); const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt()); logs[tag.toString()] = [log]; @@ -173,7 +164,7 @@ describe('Simulator oracle', () => { const firstSender = senders[0]; const tag = computeSiloedTagForIndex(firstSender, recipient.address, contractAddress, senderOffset); const payload = getRandomNoteLogPayload(tag, contractAddress); - const logData = payload.generatePayload(GrumpkinScalar.random(), recipient.address, recipientOvKeys).toBuffer(); + const logData = payload.generatePayload(GrumpkinScalar.random(), recipient.address).toBuffer(); const log = new TxScopedL2Log(TxHash.random(), 1, 0, false, logData); logs[tag.toString()].push(log); // Accumulated logs intended for recipient: NUM_SENDERS + 1 @@ -190,7 +181,6 @@ describe('Simulator oracle', () => { 1, 1, recipient.address, - recipientOvKeys, ); const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt()); logs[tag.toString()] = [log]; @@ -211,10 +201,6 @@ describe('Simulator oracle', () => { 1, 1, randomRecipient, - new KeyValidationRequest( - keys.publicKeys.masterOutgoingViewingPublicKey, - computeOvskApp(keys.masterOutgoingViewingSecretKey, contractAddress), - ), ); const log = new TxScopedL2Log(TxHash.random(), 0, blockNumber, false, randomNote.encrypt()); logs[tag.toString()] = [log]; @@ -557,7 +543,6 @@ describe('Simulator oracle', () => { 0, 2, recipient.address, - KeyValidationRequest.random(), ); const taggedLogs = mockTaggedLogs([request]); @@ -571,30 +556,6 @@ describe('Simulator oracle', () => { index: request.indexWithinNoteHashTree, }), ], - [], - recipient.address, - ); - }, 25_000); - - it('should store an outgoing note that belongs to us', async () => { - const request = new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 4, - 0, - 2, - CompleteAddress.random().address, - recipientOvKeys, - ); - - const taggedLogs = mockTaggedLogs([request]); - - await simulatorOracle.processTaggedLogs(taggedLogs, recipient.address, simulator); - - expect(addNotesSpy).toHaveBeenCalledTimes(1); - // For outgoing notes, the resulting DAO does not contain index. - expect(addNotesSpy).toHaveBeenCalledWith( - [], - [expect.objectContaining(request.snippetOfNoteDao)], recipient.address, ); }, 25_000); @@ -607,7 +568,6 @@ describe('Simulator oracle', () => { 1, 1, recipient.address, - recipientOvKeys, ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -615,7 +575,6 @@ describe('Simulator oracle', () => { 3, 0, CompleteAddress.random().address, - recipientOvKeys, ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -623,7 +582,6 @@ describe('Simulator oracle', () => { 3, 2, recipient.address, - KeyValidationRequest.random(), ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -631,7 +589,6 @@ describe('Simulator oracle', () => { 3, 2, CompleteAddress.random().address, - KeyValidationRequest.random(), ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -639,7 +596,6 @@ describe('Simulator oracle', () => { 3, 2, recipient.address, - recipientOvKeys, ), ]; @@ -664,12 +620,6 @@ describe('Simulator oracle', () => { index: requests[4].indexWithinNoteHashTree, }), ], - // Outgoing should contain notes from requests 0, 1, 4 because in those requests we set owner ovKeys. - [ - expect.objectContaining(requests[0].snippetOfNoteDao), - expect.objectContaining(requests[1].snippetOfNoteDao), - expect.objectContaining(requests[4].snippetOfNoteDao), - ], recipient.address, ); }, 30_000); @@ -683,7 +633,6 @@ describe('Simulator oracle', () => { 1, 1, CompleteAddress.random().address, - KeyValidationRequest.random(), ), new MockNoteRequest( getRandomNoteLogPayload(), @@ -691,7 +640,6 @@ describe('Simulator oracle', () => { 3, 0, CompleteAddress.random().address, - KeyValidationRequest.random(), ), ]; @@ -707,18 +655,18 @@ describe('Simulator oracle', () => { const note2 = getRandomNoteLogPayload(Fr.random(), contractAddress); // All note payloads except one have the same contract address, storage slot, and the actual note. const requests = [ - new MockNoteRequest(note, 3, 0, 0, recipient.address, recipientOvKeys), - new MockNoteRequest(note, 4, 0, 2, recipient.address, recipientOvKeys), - new MockNoteRequest(note, 4, 2, 0, recipient.address, recipientOvKeys), - new MockNoteRequest(note2, 5, 2, 1, recipient.address, recipientOvKeys), - new MockNoteRequest(note, 6, 2, 3, recipient.address, recipientOvKeys), + new MockNoteRequest(note, 3, 0, 0, recipient.address), + new MockNoteRequest(note, 4, 0, 2, recipient.address), + new MockNoteRequest(note, 4, 2, 0, recipient.address), + new MockNoteRequest(note2, 5, 2, 1, recipient.address), + new MockNoteRequest(note, 6, 2, 3, recipient.address), ]; const taggedLogs = mockTaggedLogs(requests); await simulatorOracle.processTaggedLogs(taggedLogs, recipient.address, simulator); - // First we check incoming + // Check incoming { const addedIncoming: IncomingNoteDao[] = addNotesSpy.mock.calls[0][0]; expect(addedIncoming.map(dao => dao)).toEqual([ @@ -734,20 +682,6 @@ describe('Simulator oracle', () => { addedIncoming.forEach(info => nonceSet.add(info.nonce.value)); expect(nonceSet.size).toBe(requests.length); } - - // Then we check outgoing - { - const addedOutgoing: OutgoingNoteDao[] = addNotesSpy.mock.calls[0][1]; - expect(addedOutgoing.map(dao => dao)).toEqual([ - expect.objectContaining(requests[0].snippetOfNoteDao), - expect.objectContaining(requests[1].snippetOfNoteDao), - expect.objectContaining(requests[2].snippetOfNoteDao), - expect.objectContaining(requests[3].snippetOfNoteDao), - expect.objectContaining(requests[4].snippetOfNoteDao), - ]); - - // Outgoing note daos do not have a nonce so we don't check it. - } }); it('should not store nullified notes', async () => { @@ -758,7 +692,6 @@ describe('Simulator oracle', () => { 1, 1, recipient.address, - recipientOvKeys, ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -766,7 +699,6 @@ describe('Simulator oracle', () => { 3, 2, recipient.address, - recipientOvKeys, ), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), @@ -774,7 +706,6 @@ describe('Simulator oracle', () => { 3, 2, recipient.address, - recipientOvKeys, ), ]; @@ -801,12 +732,6 @@ describe('Simulator oracle', () => { index: requests[2].indexWithinNoteHashTree, }), ], - // Outgoing should contain notes from requests 0, 1, 2 because in those requests we set owner ovKeys. - [ - expect.objectContaining(requests[0].snippetOfNoteDao), - expect.objectContaining(requests[1].snippetOfNoteDao), - expect.objectContaining(requests[2].snippetOfNoteDao), - ], recipient.address, ); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 022022db071..85dd6afd2d8 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -27,7 +27,6 @@ import { StateReference, TxContext, computeAppNullifierSecretKey, - computeOvskApp, deriveKeys, getContractInstanceFromDeployParams, getNonEmptyItems, @@ -94,9 +93,7 @@ describe('Private Execution test suite', () => { let recipientCompleteAddress: CompleteAddress; let ownerNskM: GrumpkinScalar; - let ownerOvskM: GrumpkinScalar; let recipientNskM: GrumpkinScalar; - let recipientOvskM: GrumpkinScalar; const treeHeights: { [name: string]: number } = { noteHash: NOTE_HASH_TREE_HEIGHT, @@ -188,11 +185,11 @@ describe('Private Execution test suite', () => { const ownerPartialAddress = Fr.random(); ownerCompleteAddress = CompleteAddress.fromSecretKeyAndPartialAddress(ownerSk, ownerPartialAddress); - ({ masterNullifierSecretKey: ownerNskM, masterOutgoingViewingSecretKey: ownerOvskM } = deriveKeys(ownerSk)); + ({ masterNullifierSecretKey: ownerNskM } = deriveKeys(ownerSk)); const recipientPartialAddress = Fr.random(); recipientCompleteAddress = CompleteAddress.fromSecretKeyAndPartialAddress(recipientSk, recipientPartialAddress); - ({ masterNullifierSecretKey: recipientNskM, masterOutgoingViewingSecretKey: recipientOvskM } = + ({ masterNullifierSecretKey: recipientNskM } = deriveKeys(recipientSk)); owner = ownerCompleteAddress.address; @@ -211,14 +208,6 @@ describe('Private Execution test suite', () => { ), ); } - if (pkMHash.equals(ownerCompleteAddress.publicKeys.masterOutgoingViewingPublicKey.hash())) { - return Promise.resolve( - new KeyValidationRequest( - ownerCompleteAddress.publicKeys.masterOutgoingViewingPublicKey, - computeOvskApp(ownerOvskM, contractAddress), - ), - ); - } if (pkMHash.equals(recipientCompleteAddress.publicKeys.masterNullifierPublicKey.hash())) { return Promise.resolve( new KeyValidationRequest( @@ -227,14 +216,6 @@ describe('Private Execution test suite', () => { ), ); } - if (pkMHash.equals(recipientCompleteAddress.publicKeys.masterOutgoingViewingPublicKey.hash())) { - return Promise.resolve( - new KeyValidationRequest( - recipientCompleteAddress.publicKeys.masterOutgoingViewingPublicKey, - computeOvskApp(recipientOvskM, contractAddress), - ), - ); - } throw new Error(`Unknown master public key hash: ${pkMHash}`); }); @@ -275,9 +256,8 @@ describe('Private Execution test suite', () => { // NB: this test does NOT cover correct enc/dec of values, just whether // the contexts correctly populate non-note encrypted logs const artifact = getFunctionArtifact(TestContractArtifact, 'emit_array_as_encrypted_log'); - // We emit the outgoing here to recipient for no reason at all - const outgoingViewer = recipient; - const args = [times(5, () => Fr.random()), owner, outgoingViewer, false]; + const sender = recipient; // Needed for tagging. + const args = [times(5, () => Fr.random()), owner, sender, false]; const result = await runSimulator({ artifact, msgSender: owner, args }); const privateLogs = getNonEmptyItems(result.publicInputs.privateLogs); @@ -884,8 +864,8 @@ describe('Private Execution test suite', () => { const contractAddress = AztecAddress.random(); const artifact = getFunctionArtifact(PendingNoteHashesContractArtifact, 'test_insert_then_get_then_nullify_flat'); - const outgoingViewer = owner; - const args = [amountToTransfer, owner, outgoingViewer]; + const sender = owner; + const args = [amountToTransfer, owner, sender]; const result = await runSimulator({ args: args, artifact: artifact, @@ -954,11 +934,11 @@ describe('Private Execution test suite', () => { getThenNullifyArtifact.parameters, ); - const outgoingViewer = owner; + const sender = owner; const args = [ amountToTransfer, owner, - outgoingViewer, + sender, insertFnSelector.toField(), getThenNullifyFnSelector.toField(), ]; From a28c87eac3194515094b14246d811e5b32b43794 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Sun, 8 Dec 2024 21:11:51 +0000 Subject: [PATCH 02/29] nargo fmt --- .../aztec-nr/aztec/src/context/private_context.nr | 7 +++++-- .../aztec/src/encrypted_logs/encrypted_note_emission.nr | 8 +++++--- noir-projects/aztec-nr/aztec/src/note/lifecycle.nr | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index a9e80762966..e60d2d5f826 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; +use dep::protocol_types::debug_log::{debug_log, debug_log_format}; use crate::{ context::{inputs::PrivateContextInputs, packed_returns::PackedReturns}, @@ -139,7 +139,10 @@ impl PrivateContext { pub fn push_note_hash(&mut self, note_hash: Field) { self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); - debug_log_format("\nPushed new note hash: (note_hash:{0}, counter: {1})", [note_hash, (self.side_effect_counter - 1) as Field]); + debug_log_format( + "\nPushed new note hash: (note_hash:{0}, counter: {1})", + [note_hash, (self.side_effect_counter - 1) as Field], + ); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index b8109382a57..c536960cceb 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; +use dep::protocol_types::debug_log::{debug_log, debug_log_format}; use crate::{ context::PrivateContext, @@ -23,8 +23,10 @@ where let note_hash_counter = note_header.note_hash_counter; let storage_slot = note_header.storage_slot; - debug_log_format("\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", [note_hash_counter as Field, storage_slot]); - + debug_log_format( + "\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", + [note_hash_counter as Field, storage_slot], + ); // TODO(#8589): use typesystem to skip this check when not needed let note_exists = diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index e1e40597816..9c4b3a40a5a 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::debug_log::{ debug_log, debug_log_format }; +use dep::protocol_types::debug_log::{debug_log, debug_log_format}; use crate::context::{PrivateContext, PublicContext}; use crate::note::{ @@ -20,7 +20,10 @@ where let contract_address = (*context).this_address(); let note_hash_counter = context.side_effect_counter; - debug_log_format("\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", [note_hash_counter as Field, storage_slot]); + debug_log_format( + "\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", + [note_hash_counter as Field, storage_slot], + ); let header = NoteHeader { contract_address, storage_slot, nonce: 0, note_hash_counter }; note.set_header(header); From 0593f5dd093d25a7c865c9206e6815fbaade31fa Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Sun, 8 Dec 2024 22:22:30 +0000 Subject: [PATCH 03/29] update payload test snapshot --- .../aztec/src/encrypted_logs/payload.nr | 21 +------------------ .../l1_payload/encrypted_log_payload.test.ts | 3 +-- .../logs/l1_payload/encrypted_log_payload.ts | 6 ++++-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 43033a5e984..3e5bd340d4c 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -268,26 +268,7 @@ mod test { // The following value was generated by `encrypted_log_payload.test.ts` // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. - let private_log_payload_from_typescript = [ - 0x0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36, - 0x008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f, - 0x00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9, - 0x003de818923f85187871d99bdf95d695eff0a9e09ba15153fc9b4d224b6e1e71, - 0x00dfbdcaab06c09d5b3c749bfebe1c0407eccd04f51bbb59142680c8a091b97f, - 0x00c6cbcf615def593ab09e5b3f7f58f6fc235c90e7c77ed8dadb3b05ee4545a7, - 0x00bc612c9139475fee6070be47efcc43a5cbbc873632f1428fac952df9c181db, - 0x005f9e850b21fe11fedef37b88caee95111bce776e488df219732d0a77d19201, - 0x007047186f41445ecd5c603487f7fb3c8f31010a22af69ce0000000000000000, - 0x0000000000000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba, - 0x009dc0cec8c70b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b72, - 0x0095748ad19c1083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd5, - 0x009b3781c9c02a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b95162, - 0x00a6e9d067655cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf6, - 0x002c2f49f549f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e25, - 0x00881548ec9606a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f8, - 0x009970aeb3d9489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea192, - 0x0022fb10df358c765edada497db4284ae30507a2e03e983d23cfa0bd831577e8, - ]; + let private_log_payload_from_typescript = [0x0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36,0x008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f,0x00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9,0x003de818923f85187871d99bdf95d695eff0a900000000000000000000000000,0x000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba9dc0cec8c7,0x000b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b7295748ad19c,0x001083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd59b3781c9c0,0x002a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b95162a6e9d06765,0x005cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf62c2f49f549,0x00f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e25881548ec96,0x0006a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f89970aeb3d9,0x00489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea19222fb10df35,0x008c765edada497db4284ae30507a2e03e983d23cfa0bd831577e857bbef9cf7,0x0090c97cb5699cc8783a1b4276d929be2882e5b9b72829a4f8404f7e3c853d11,0x00d6d5a000b80134891e95f81007ad35d3945eaeecbe137fff85d01d7eaf8f19,0x00a15eb965c6a4bc97aa87fd3463c31c9d4e0d722a8ba870bcc50c9c7a8b48ad,0x0063c861bdbe490d44c57382decbae663927909652f87ac18dcfd5b30649cce5,0x00820f14caa725efe1fa3485ceac88499eadf0565c5b20998c05931bbf478e68]; assert_eq(payload, private_log_payload_from_typescript); } diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts index 6da6d0f200b..dd9a6aff630 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts @@ -88,7 +88,6 @@ describe('EncryptedLogPayload', () => { // ); // }); - // TODO: why is this using ov keys, and not iv keys? it('encrypted tagged log matches Noir', () => { // All the values in this test were arbitrarily set and copied over to `payload.nr` const contract = AztecAddress.fromString('0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04'); @@ -117,7 +116,7 @@ describe('EncryptedLogPayload', () => { const payload = log.generatePayload(ephSk, recipientCompleteAddress.address, fixedRand); expect(payload.toBuffer().toString('hex')).toMatchInlineSnapshot( - `"0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9003de818923f85187871d99bdf95d695eff0a9e09ba15153fc9b4d224b6e1e7100dfbdcaab06c09d5b3c749bfebe1c0407eccd04f51bbb59142680c8a091b97f00c6cbcf615def593ab09e5b3f7f58f6fc235c90e7c77ed8dadb3b05ee4545a700bc612c9139475fee6070be47efcc43a5cbbc873632f1428fac952df9c181db005f9e850b21fe11fedef37b88caee95111bce776e488df219732d0a77d19201007047186f41445ecd5c603487f7fb3c8f31010a22af69ce00000000000000000000000000000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba009dc0cec8c70b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b720095748ad19c1083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd5009b3781c9c02a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b9516200a6e9d067655cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf6002c2f49f549f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e2500881548ec9606a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f8009970aeb3d9489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea1920022fb10df358c765edada497db4284ae30507a2e03e983d23cfa0bd831577e8"`, + `"0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9003de818923f85187871d99bdf95d695eff0a900000000000000000000000000000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba9dc0cec8c7000b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b7295748ad19c001083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd59b3781c9c0002a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b95162a6e9d06765005cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf62c2f49f54900f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e25881548ec960006a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f89970aeb3d900489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea19222fb10df35008c765edada497db4284ae30507a2e03e983d23cfa0bd831577e857bbef9cf70090c97cb5699cc8783a1b4276d929be2882e5b9b72829a4f8404f7e3c853d1100d6d5a000b80134891e95f81007ad35d3945eaeecbe137fff85d01d7eaf8f1900a15eb965c6a4bc97aa87fd3463c31c9d4e0d722a8ba870bcc50c9c7a8b48ad0063c861bdbe490d44c57382decbae663927909652f87ac18dcfd5b30649cce500820f14caa725efe1fa3485ceac88499eadf0565c5b20998c05931bbf478e68"`, ); // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts index a5a647e424e..a758c19c121 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts @@ -16,6 +16,8 @@ import { decrypt, encrypt } from './encryption_util.js'; // Below constants should match the values defined in aztec-nr/aztec/src/encrypted_logs/payload.nr. +const ENCRYPTED_PAYLOAD_SIZE_IN_BYTES = (PRIVATE_LOG_SIZE_IN_FIELDS - 1) * 31; + // The incoming header is 48 bytes../shared_secret_derivation.js // 32 bytes for the address, and 16 bytes padding to follow PKCS#7 const HEADER_SIZE = 48; @@ -28,10 +30,10 @@ const OVERHEAD_SIZE = HEADER_SIZE /* incoming_header */ + OVERHEAD_PADDING; /* padding */ -const ENCRYPTED_PAYLOAD_SIZE_IN_BYTES = (PRIVATE_LOG_SIZE_IN_FIELDS - 1) * 31; +const PLAINTEXT_LENGTH_SIZE = 2; const MAX_PRIVATE_LOG_PLAINTEXT_SIZE_IN_BYTES = - ENCRYPTED_PAYLOAD_SIZE_IN_BYTES - OVERHEAD_SIZE - 2 /* plaintext */ - 1; /* aes padding */ + ENCRYPTED_PAYLOAD_SIZE_IN_BYTES - OVERHEAD_SIZE - PLAINTEXT_LENGTH_SIZE - 1; /* aes padding */ function encryptedBytesToFields(encrypted: Buffer): Fr[] { const fields = []; From eccf14f4ea4c9b1aed8f258b4e2df07155cf197c Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Sun, 8 Dec 2024 23:25:54 +0000 Subject: [PATCH 04/29] fix test --- .../end-to-end/src/e2e_event_logs.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_event_logs.test.ts b/yarn-project/end-to-end/src/e2e_event_logs.test.ts index 65901a86972..cdaf45e61d6 100644 --- a/yarn-project/end-to-end/src/e2e_event_logs.test.ts +++ b/yarn-project/end-to-end/src/e2e_event_logs.test.ts @@ -120,17 +120,17 @@ describe('Logs', () => { ); expect(collectedEvent0sWithIncoming.length).toBe(5); - expect(collectedEvent0s.length).toBe(10); + expect(collectedEvent0s.length).toBe(5); expect(collectedEvent1s.length).toBe(5); - // const emptyEvent1s = await wallets[0].getEncryptedEvents( - // TestLogContract.events.ExampleEvent1, - // firstBlockNumber, - // numBlocks, - // [wallets[0].getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey], - // ); + const emptyEvent1s = await wallets[0].getEncryptedEvents( + TestLogContract.events.ExampleEvent1, + firstBlockNumber, + numBlocks, + [wallets[0].getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey], + ); - // expect(emptyEvent1s.length).toBe(0); + expect(emptyEvent1s.length).toBe(0); const exampleEvent0Sort = (a: ExampleEvent0, b: ExampleEvent0) => (a.value0 > b.value0 ? 1 : -1); expect(collectedEvent0sWithIncoming.sort(exampleEvent0Sort)).toStrictEqual( From 7a1766ac144606b6c5cab7c313928eab624b8a44 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Sun, 8 Dec 2024 23:32:39 +0000 Subject: [PATCH 05/29] argh fmt --- .../aztec/src/encrypted_logs/payload.nr | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 3e5bd340d4c..56d14f341bc 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -268,7 +268,26 @@ mod test { // The following value was generated by `encrypted_log_payload.test.ts` // --> Run the test with AZTEC_GENERATE_TEST_DATA=1 flag to update test data. - let private_log_payload_from_typescript = [0x0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36,0x008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f,0x00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9,0x003de818923f85187871d99bdf95d695eff0a900000000000000000000000000,0x000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba9dc0cec8c7,0x000b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b7295748ad19c,0x001083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd59b3781c9c0,0x002a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b95162a6e9d06765,0x005cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf62c2f49f549,0x00f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e25881548ec96,0x0006a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f89970aeb3d9,0x00489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea19222fb10df35,0x008c765edada497db4284ae30507a2e03e983d23cfa0bd831577e857bbef9cf7,0x0090c97cb5699cc8783a1b4276d929be2882e5b9b72829a4f8404f7e3c853d11,0x00d6d5a000b80134891e95f81007ad35d3945eaeecbe137fff85d01d7eaf8f19,0x00a15eb965c6a4bc97aa87fd3463c31c9d4e0d722a8ba870bcc50c9c7a8b48ad,0x0063c861bdbe490d44c57382decbae663927909652f87ac18dcfd5b30649cce5,0x00820f14caa725efe1fa3485ceac88499eadf0565c5b20998c05931bbf478e68]; + let private_log_payload_from_typescript = [ + 0x0e9cffc3ddd746affb02410d8f0a823e89939785bcc8e88ee4f3cae05e737c36, + 0x008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701f, + 0x00a70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d9, + 0x003de818923f85187871d99bdf95d695eff0a900000000000000000000000000, + 0x000000a600a61f7d59eeaf52eb51bc0592ff981d9ba3ea8e6ea8ba9dc0cec8c7, + 0x000b81e84556a77ce6c3ca47a527f99ffe7b2524bb885a23020b7295748ad19c, + 0x001083618ad96298b76ee07eb1a56d19cc798710e9f5de96501bd59b3781c9c0, + 0x002a6c95c5912f8936b1500d362afbf0922c85b1ada18db8b95162a6e9d06765, + 0x005cdf669eb387f8e0492a95fdcdb39429d5340b4bebc250ba9bf62c2f49f549, + 0x00f37beed75a668aa51967e0e57547e5a655157bcf381e22f30e25881548ec96, + 0x0006a151b5fbfb2d14ee4b34bf4c1dbd71c7be15ad4c63474bb6f89970aeb3d9, + 0x00489c8edbdff80a1a3a5c28370e534abc870a85ea4318326ea19222fb10df35, + 0x008c765edada497db4284ae30507a2e03e983d23cfa0bd831577e857bbef9cf7, + 0x0090c97cb5699cc8783a1b4276d929be2882e5b9b72829a4f8404f7e3c853d11, + 0x00d6d5a000b80134891e95f81007ad35d3945eaeecbe137fff85d01d7eaf8f19, + 0x00a15eb965c6a4bc97aa87fd3463c31c9d4e0d722a8ba870bcc50c9c7a8b48ad, + 0x0063c861bdbe490d44c57382decbae663927909652f87ac18dcfd5b30649cce5, + 0x00820f14caa725efe1fa3485ceac88499eadf0565c5b20998c05931bbf478e68, + ]; assert_eq(payload, private_log_payload_from_typescript); } From 2cdd5c1c342715e7875b44e10f9f7d09dc868bc8 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 10:49:15 +0000 Subject: [PATCH 06/29] convenience script to rebuild one contract --- .../scripts/bootstraph_just_one_contract.sh | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh diff --git a/noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh b/noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh new file mode 100755 index 00000000000..cb803d6294d --- /dev/null +++ b/noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +set -eu + +cd "$(dirname "$0")" + +# Call example: +# `./scripts/bootstraph_just_one_contract.sh nft_contract NFT` + +# Check if the filename argument is provided +if [ "$#" -lt 2 ]; then + echo "Usage: $0 [command]" + echo "The filename should be as per those spat out into the 'target/' dir, without json. E.g. 'nft_contract NFT'" + exit 1 +fi + +CONTRACT_PACKAGE_NAME=$1 +CONTRACT_NAME=$2 +JSON_NAME="$CONTRACT_PACKAGE_NAME-$CONTRACT_NAME" + +CMD=${3:-} # Check for a 3rd arg that shouldn't be there. + +# Handle the "clean" command +if [ -n "$CMD" ]; then + echo "Unknown command: $CMD" + exit 1 +fi + +# Ensure the target JSON file exists +if [ ! -f "../target/$JSON_NAME.json" ]; then + echo "Error: File '../target/$JSON_NAME.json' not found." + exit 1 +fi + +# Compile the contract +echo "Compiling contract..." +NARGO=${NARGO:-../../../noir/noir-repo/target/release/nargo} +$NARGO compile --silence-warnings --inliner-aggressiveness 0 --package $CONTRACT_PACKAGE_NAME + +# Transpile the contract +echo "Transpiling contract..." +TRANSPILER=${TRANSPILER:-../../../avm-transpiler/target/release/avm-transpiler} +"$TRANSPILER" "../target/$JSON_NAME.json" "../target/$JSON_NAME.json" + +# Postprocess the contract +echo "Postprocessing contract..." +BB_HASH=${BB_HASH:-$(cd ../../../ && git ls-tree -r HEAD | grep 'barretenberg/cpp' | awk '{print $3}' | git hash-object --stdin)} +echo "Using BB hash $BB_HASH" + +tempDir="../target/tmp" +mkdir -p "$tempDir" + +BB_HASH=$BB_HASH node ./postprocess_contract.js "../target/$JSON_NAME.json" "$tempDir" + From 762e057071e294c706b5d3c6ca9d8795f8e449b4 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 10:49:39 +0000 Subject: [PATCH 07/29] some temp logs --- .../aztec-nr/aztec/src/context/private_context.nr | 9 +++++++-- .../aztec/src/encrypted_logs/encrypted_note_emission.nr | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index e60d2d5f826..3fd3c4adc94 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -138,11 +138,16 @@ impl PrivateContext { } pub fn push_note_hash(&mut self, note_hash: Field) { - self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); debug_log_format( - "\nPushed new note hash: (note_hash:{0}, counter: {1})", + "\n\nMIKE About to push new note hash: (note_hash:{0}, counter: {1})", [note_hash, (self.side_effect_counter - 1) as Field], ); + self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); + debug_log("And just to make doubly sure, here is the context after pushing:"); + debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); + debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); + debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); + debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index c536960cceb..1c848ab139d 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -24,10 +24,14 @@ where let storage_slot = note_header.storage_slot; debug_log_format( - "\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", + "\n\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", [note_hash_counter as Field, storage_slot], ); + debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); + debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); + + // TODO(#8589): use typesystem to skip this check when not needed let note_exists = context.note_hashes.storage().any(|n: NoteHash| n.counter == note_hash_counter); From af8d12555528ad1ee5973a471ec876f672194bd9 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 10:50:04 +0000 Subject: [PATCH 08/29] yarn format --- .../aztec.js/src/wallet/base_wallet.ts | 4 +- yarn-project/bot/src/bot.ts | 4 +- .../logs/l1_payload/encrypted_log_payload.ts | 15 +---- .../end-to-end/src/e2e_block_building.test.ts | 7 +- .../e2e_deploy_contract/deploy_method.test.ts | 4 +- .../end-to-end/src/e2e_fees/fees_test.ts | 4 +- .../e2e_pending_note_hashes_contract.test.ts | 5 +- .../e2e_public_testnet_transfer.test.ts | 6 +- .../pxe/src/database/kv_pxe_database.ts | 12 +--- .../produce_note_daos.ts | 2 +- .../pxe/src/simulator_oracle/index.ts | 1 - .../simulator_oracle/simulator_oracle.test.ts | 64 +++---------------- .../src/client/private_execution.test.ts | 11 +--- 13 files changed, 23 insertions(+), 116 deletions(-) diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index e68033ee222..35694b490f5 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -198,9 +198,7 @@ export abstract class BaseWallet implements Wallet { event: EventMetadataDefinition, from: number, limit: number, - vpks: Point[] = [ - this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey, - ], + vpks: Point[] = [this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey], ): Promise { return this.pxe.getEncryptedEvents(event, from, limit, vpks); } diff --git a/yarn-project/bot/src/bot.ts b/yarn-project/bot/src/bot.ts index a2ff17876b1..157aa67e584 100644 --- a/yarn-project/bot/src/bot.ts +++ b/yarn-project/bot/src/bot.ts @@ -64,9 +64,7 @@ export class Bot { ); } else { calls.push( - ...times(privateTransfersPerTx, () => - token.methods.transfer(TRANSFER_AMOUNT, sender, recipient).request(), - ), + ...times(privateTransfersPerTx, () => token.methods.transfer(TRANSFER_AMOUNT, sender, recipient).request()), ); } diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts index a758c19c121..cde665e1747 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts @@ -25,10 +25,7 @@ const HEADER_SIZE = 48; // Padding added to the overhead to make the size of the incoming body ciphertext a multiple of 16. const OVERHEAD_PADDING = 15; -const OVERHEAD_SIZE = - 32 /* eph_pk */ + - HEADER_SIZE /* incoming_header */ + - OVERHEAD_PADDING; /* padding */ +const OVERHEAD_SIZE = 32 /* eph_pk */ + HEADER_SIZE /* incoming_header */ + OVERHEAD_PADDING; /* padding */ const PLAINTEXT_LENGTH_SIZE = 2; @@ -49,10 +46,7 @@ function fieldsToEncryptedBytes(fields: Fr[]) { } class Overhead { - constructor( - public ephPk: Point, - public incomingHeader: Buffer, - ) {} + constructor(public ephPk: Point, public incomingHeader: Buffer) {} static fromBuffer(reader: BufferReader) { const ephPk = Point.fromCompressedBuffer(reader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); @@ -212,10 +206,7 @@ export class EncryptedLogPayload { return serializeToBuffer(this.tag, this.contractAddress.toBuffer(), this.incomingBodyPlaintext); } - static #decryptOverhead( - overhead: Overhead, - { addressSecret }: { addressSecret: GrumpkinScalar }, - ) { + static #decryptOverhead(overhead: Overhead, { addressSecret }: { addressSecret: GrumpkinScalar }) { let contractAddress = AztecAddress.ZERO; if (addressSecret) { diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index e3e02121149..1651605d21e 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -322,12 +322,7 @@ describe('e2e_block_building', () => { // call test contract const values = [new Fr(5), new Fr(4), new Fr(3), new Fr(2), new Fr(1)]; const nestedValues = [new Fr(0), new Fr(0), new Fr(0), new Fr(0), new Fr(0)]; - const action = testContract.methods.emit_array_as_encrypted_log( - values, - thisWallet.getAddress(), - sender, - true, - ); + const action = testContract.methods.emit_array_as_encrypted_log(values, thisWallet.getAddress(), sender, true); const tx = await action.prove(); const rct = await tx.send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index c3e2249c1cd..59191866b8e 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -67,9 +67,7 @@ describe('e2e_deploy_contract deploy method', () => { it('deploys a contract with a default initializer not named constructor', async () => { logger.debug(`Deploying contract with a default initializer named initialize`); const opts = { skipClassRegistration: true, skipPublicDeployment: true }; - const contract = await CounterContract.deploy(wallet, 10, wallet.getAddress()) - .send(opts) - .deployed(); + const contract = await CounterContract.deploy(wallet, 10, wallet.getAddress()).send(opts).deployed(); logger.debug(`Calling a function to ensure the contract was properly initialized`); await contract.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait(); expect(await contract.methods.get_counter(wallet.getAddress()).simulate()).toEqual(11n); diff --git a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts index 90f29398ad2..2cad109d71e 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts @@ -299,9 +299,7 @@ export class FeesTest { await this.snapshotManager.snapshot( 'setup_subscription', async () => { - const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress) - .send() - .deployed(); + const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed(); // Deploy subscription contract, that allows subscriptions for SUBSCRIPTION_AMOUNT of bananas const subscriptionContract = await AppSubscriptionContract.deploy( diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index b546e5a4fec..248d81c9cf9 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -77,10 +77,7 @@ describe('e2e_pending_note_hashes_contract', () => { const deployedContract = await deployContract(); const sender = owner; - await deployedContract.methods - .test_insert_then_get_then_nullify_flat(mintAmount, owner, sender) - .send() - .wait(); + await deployedContract.methods.test_insert_then_get_then_nullify_flat(mintAmount, owner, sender).send().wait(); }); it('Squash! Aztec.nr function can "create" and "nullify" note in the same TX', async () => { diff --git a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts index b436499297e..eb395bd0e46 100644 --- a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts +++ b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts @@ -43,11 +43,7 @@ describe(`deploys and transfers a private only token`, () => { const [deployerWallet, recipientWallet] = accounts; - const token = await EasyPrivateTokenContract.deploy( - deployerWallet, - initialBalance, - deployerWallet.getAddress(), - ) + const token = await EasyPrivateTokenContract.deploy(deployerWallet, initialBalance, deployerWallet.getAddress()) .send({ universalDeploy: true, skipPublicDeployment: true, diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index ef9d7e290bf..06d0719ff92 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -1,9 +1,4 @@ -import { - type InBlock, - type IncomingNotesFilter, - MerkleTreeId, - NoteStatus, -} from '@aztec/circuit-types'; +import { type InBlock, type IncomingNotesFilter, MerkleTreeId, NoteStatus } from '@aztec/circuit-types'; import { AztecAddress, BlockHeader, @@ -190,10 +185,7 @@ export class KVPxeDatabase implements PxeDatabase { await this.addNotes([note], scope); } - async addNotes( - incomingNotes: IncomingNoteDao[], - scope: AztecAddress = AztecAddress.ZERO, - ): Promise { + async addNotes(incomingNotes: IncomingNoteDao[], scope: AztecAddress = AztecAddress.ZERO): Promise { if (!this.#scopes.has(scope.toString())) { await this.#addScope(scope); } diff --git a/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts index 6d4fe005ee7..870150627a7 100644 --- a/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts +++ b/yarn-project/pxe/src/note_decryption_utils/produce_note_daos.ts @@ -37,7 +37,7 @@ export async function produceNoteDaos( dataStartIndexForTx: number, excludedIndices: Set, logger: Logger, -): Promise<{incomingNote: IncomingNoteDao | undefined}> { +): Promise<{ incomingNote: IncomingNoteDao | undefined }> { if (!addressPoint) { throw new Error('addressPoint is undefined. Cannot create note.'); } diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 40c9b37a3a9..cdf137ebde2 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -550,7 +550,6 @@ export class SimulatorOracle implements DBOracle { : L1NotePayload.decryptAsIncoming(PrivateLog.fromBuffer(scopedLog.logData), addressSecret); if (incomingNotePayload) { - const payload = incomingNotePayload; const txEffect = diff --git a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts index 9694b562bc5..8d45e27b31e 100644 --- a/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts +++ b/yarn-project/pxe/src/simulator_oracle/simulator_oracle.test.ts @@ -562,13 +562,7 @@ describe('Simulator oracle', () => { it('should store multiple notes that belong to us', async () => { const requests = [ - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 1, - 1, - 1, - recipient.address, - ), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 1, 1, 1, recipient.address), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), 2, @@ -576,13 +570,7 @@ describe('Simulator oracle', () => { 0, CompleteAddress.random().address, ), - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 6, - 3, - 2, - recipient.address, - ), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 6, 3, 2, recipient.address), new MockNoteRequest( getRandomNoteLogPayload(Fr.random(), contractAddress), 9, @@ -590,13 +578,7 @@ describe('Simulator oracle', () => { 2, CompleteAddress.random().address, ), - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 12, - 3, - 2, - recipient.address, - ), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 12, 3, 2, recipient.address), ]; const taggedLogs = mockTaggedLogs(requests); @@ -627,20 +609,8 @@ describe('Simulator oracle', () => { it('should not store notes that do not belong to us', async () => { // Both notes should be ignored because the encryption keys do not belong to owner (they are random). const requests = [ - new MockNoteRequest( - getRandomNoteLogPayload(), - 2, - 1, - 1, - CompleteAddress.random().address, - ), - new MockNoteRequest( - getRandomNoteLogPayload(), - 2, - 3, - 0, - CompleteAddress.random().address, - ), + new MockNoteRequest(getRandomNoteLogPayload(), 2, 1, 1, CompleteAddress.random().address), + new MockNoteRequest(getRandomNoteLogPayload(), 2, 3, 0, CompleteAddress.random().address), ]; const taggedLogs = mockTaggedLogs(requests); @@ -686,27 +656,9 @@ describe('Simulator oracle', () => { it('should not store nullified notes', async () => { const requests = [ - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 1, - 1, - 1, - recipient.address, - ), - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 6, - 3, - 2, - recipient.address, - ), - new MockNoteRequest( - getRandomNoteLogPayload(Fr.random(), contractAddress), - 12, - 3, - 2, - recipient.address, - ), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 1, 1, 1, recipient.address), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 6, 3, 2, recipient.address), + new MockNoteRequest(getRandomNoteLogPayload(Fr.random(), contractAddress), 12, 3, 2, recipient.address), ]; const taggedLogs = mockTaggedLogs(requests, 2); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 85dd6afd2d8..cb21ba6f642 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -189,8 +189,7 @@ describe('Private Execution test suite', () => { const recipientPartialAddress = Fr.random(); recipientCompleteAddress = CompleteAddress.fromSecretKeyAndPartialAddress(recipientSk, recipientPartialAddress); - ({ masterNullifierSecretKey: recipientNskM } = - deriveKeys(recipientSk)); + ({ masterNullifierSecretKey: recipientNskM } = deriveKeys(recipientSk)); owner = ownerCompleteAddress.address; recipient = recipientCompleteAddress.address; @@ -935,13 +934,7 @@ describe('Private Execution test suite', () => { ); const sender = owner; - const args = [ - amountToTransfer, - owner, - sender, - insertFnSelector.toField(), - getThenNullifyFnSelector.toField(), - ]; + const args = [amountToTransfer, owner, sender, insertFnSelector.toField(), getThenNullifyFnSelector.toField()]; const result = await runSimulator({ args: args, artifact: artifact, From 8b0db81306c580179bdb46fc5329151fb6621e39 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 11:25:12 +0000 Subject: [PATCH 09/29] rm debug logs --- .../aztec/src/context/private_context.nr | 18 +++++++++--------- .../encrypted_logs/encrypted_note_emission.nr | 12 ++++++------ .../aztec-nr/aztec/src/note/lifecycle.nr | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 3fd3c4adc94..d831d421f7e 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -138,16 +138,16 @@ impl PrivateContext { } pub fn push_note_hash(&mut self, note_hash: Field) { - debug_log_format( - "\n\nMIKE About to push new note hash: (note_hash:{0}, counter: {1})", - [note_hash, (self.side_effect_counter - 1) as Field], - ); + // debug_log_format( + // "\n\nMIKE About to push new note hash: (note_hash:{0}, counter: {1})", + // [note_hash, (self.side_effect_counter - 1) as Field], + // ); self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); - debug_log("And just to make doubly sure, here is the context after pushing:"); - debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); - debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); - debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); - debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); + // debug_log("And just to make doubly sure, here is the context after pushing:"); + // debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); + // debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); + // debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); + // debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 1c848ab139d..e31a7cd4574 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -23,13 +23,13 @@ where let note_hash_counter = note_header.note_hash_counter; let storage_slot = note_header.storage_slot; - debug_log_format( - "\n\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", - [note_hash_counter as Field, storage_slot], - ); + // debug_log_format( + // "\n\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", + // [note_hash_counter as Field, storage_slot], + // ); - debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); - debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); + // debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); + // debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); // TODO(#8589): use typesystem to skip this check when not needed diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index 9c4b3a40a5a..298c27c3343 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -20,10 +20,10 @@ where let contract_address = (*context).this_address(); let note_hash_counter = context.side_effect_counter; - debug_log_format( - "\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", - [note_hash_counter as Field, storage_slot], - ); + // debug_log_format( + // "\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", + // [note_hash_counter as Field, storage_slot], + // ); let header = NoteHeader { contract_address, storage_slot, nonce: 0, note_hash_counter }; note.set_header(header); From fcca441719ce103af05cffd279f711bd933fad11 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 11:32:19 +0000 Subject: [PATCH 10/29] nargo fmt --- .../aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr | 1 - 1 file changed, 1 deletion(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index e31a7cd4574..c9dc89988f7 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -31,7 +31,6 @@ where // debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); // debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); - // TODO(#8589): use typesystem to skip this check when not needed let note_exists = context.note_hashes.storage().any(|n: NoteHash| n.counter == note_hash_counter); From 415d78847220e6918fcdb4346065c3e8cbe46b87 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 12:57:23 +0000 Subject: [PATCH 11/29] debug logs --- .../aztec-nr/aztec/src/context/private_context.nr | 10 +++++++--- .../src/encrypted_logs/encrypted_note_emission.nr | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index d831d421f7e..37c6b4ad3f8 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -144,10 +144,14 @@ impl PrivateContext { // ); self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); // debug_log("And just to make doubly sure, here is the context after pushing:"); - // debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); + + // WARNING: if you delete this debug_log_format line, some tests fail. Be safe out there. + debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); + // debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); - // debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); - // debug_log_format("And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); + // debug_log_format("\n\nMIKE - if you see a value here, the note hash is definitely in the context. self.note_hashes.storage()[0].value: {0}", [self.note_hashes.storage()[0].value]); + // debug_log_format("\n\nMIKE And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); + // debug_log_format("\n\nMIKE And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index c9dc89988f7..4ddcf3e0c6a 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -28,7 +28,7 @@ where // [note_hash_counter as Field, storage_slot], // ); - // debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); + debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); // debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); // TODO(#8589): use typesystem to skip this check when not needed From 82dfe288e915ff53bd60995db4e5820e39a4219f Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 17:43:19 +0000 Subject: [PATCH 12/29] nasty debug metadata bug --- noir-projects/aztec-nr/value-note/src/utils.nr | 1 - yarn-project/foundation/src/abi/abi.ts | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index c1ba4aebb22..eb672e07527 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -1,6 +1,5 @@ use crate::{filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; -use dep::aztec::keys::getters::get_public_keys; use dep::aztec::note::note_getter_options::SortOrder; use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, PrivateContext, PrivateSet}; diff --git a/yarn-project/foundation/src/abi/abi.ts b/yarn-project/foundation/src/abi/abi.ts index 4ba09fb11a9..afd0901ca14 100644 --- a/yarn-project/foundation/src/abi/abi.ts +++ b/yarn-project/foundation/src/abi/abi.ts @@ -8,6 +8,7 @@ import { type ZodFor } from '../schemas/types.js'; import { type FunctionSelector } from './function_selector.js'; import { type NoteSelector } from './note_selector.js'; + /** A basic value. */ export interface BasicValue { /** The kind of the value. */ @@ -390,7 +391,14 @@ export function getFunctionArtifact( if (!functionArtifact) { throw new Error(`Unknown function ${functionNameOrSelector}`); } - const debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact); + // TODO(#10546) investigate why debugMetadata was so big, for some tests https://github.com/AztecProtocol/aztec-packages/issues/10546, and whether it even needs to be retrieved at all, here. + let debugMetadata = undefined; + try { + debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact); + } catch (err: any) { + // It's likely that the debug_symbols string is too large. + // We'll accept debugMetadata = undefined in this case. + } return { ...functionArtifact, debug: debugMetadata }; } From c51ec331963d48b109de4c2849222acab1cce838 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 18:00:42 +0000 Subject: [PATCH 13/29] yarn format --- yarn-project/foundation/src/abi/abi.ts | 1 - yarn-project/kv-store/.mocharc.json | 17 +++++------------ yarn-project/kv-store/package.local.json | 8 ++++---- .../kv-store/web-test-runner.config.mjs | 4 ++-- yarn-project/pxe/package.local.json | 12 ++++++------ .../pxe/scripts/generate_package_info.js | 9 +++++---- .../pxe/src/database/kv_pxe_database.ts | 5 +---- 7 files changed, 23 insertions(+), 33 deletions(-) diff --git a/yarn-project/foundation/src/abi/abi.ts b/yarn-project/foundation/src/abi/abi.ts index afd0901ca14..d2d8462f5a2 100644 --- a/yarn-project/foundation/src/abi/abi.ts +++ b/yarn-project/foundation/src/abi/abi.ts @@ -8,7 +8,6 @@ import { type ZodFor } from '../schemas/types.js'; import { type FunctionSelector } from './function_selector.js'; import { type NoteSelector } from './note_selector.js'; - /** A basic value. */ export interface BasicValue { /** The kind of the value. */ diff --git a/yarn-project/kv-store/.mocharc.json b/yarn-project/kv-store/.mocharc.json index f6d8ef05651..5a2ff0385b7 100644 --- a/yarn-project/kv-store/.mocharc.json +++ b/yarn-project/kv-store/.mocharc.json @@ -1,13 +1,6 @@ { - "require": "ts-node/register", - "extensions": [ - "ts" - ], - "spec": [ - "./src/**/!(indexeddb)/*.test.ts" - ], - "node-option": [ - "experimental-specifier-resolution=node", - "loader=ts-node/esm" - ] - } + "require": "ts-node/register", + "extensions": ["ts"], + "spec": ["./src/**/!(indexeddb)/*.test.ts"], + "node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"] +} diff --git a/yarn-project/kv-store/package.local.json b/yarn-project/kv-store/package.local.json index 1604caf6ae8..d93348f5328 100644 --- a/yarn-project/kv-store/package.local.json +++ b/yarn-project/kv-store/package.local.json @@ -1,5 +1,5 @@ { - "scripts": { - "test": "yarn test:node && yarn test:browser" - } -} \ No newline at end of file + "scripts": { + "test": "yarn test:node && yarn test:browser" + } +} diff --git a/yarn-project/kv-store/web-test-runner.config.mjs b/yarn-project/kv-store/web-test-runner.config.mjs index 19811eec487..0458e1fe9a9 100644 --- a/yarn-project/kv-store/web-test-runner.config.mjs +++ b/yarn-project/kv-store/web-test-runner.config.mjs @@ -1,8 +1,8 @@ +import { esbuildPlugin } from '@web/dev-server-esbuild'; import { defaultReporter } from '@web/test-runner'; import { summaryReporter } from '@web/test-runner'; -import { fileURLToPath } from 'url'; -import { esbuildPlugin } from '@web/dev-server-esbuild'; import { playwrightLauncher } from '@web/test-runner-playwright'; +import { fileURLToPath } from 'url'; const reporter = process.env.CI ? summaryReporter() : defaultReporter(); diff --git a/yarn-project/pxe/package.local.json b/yarn-project/pxe/package.local.json index ee72375cfea..fab0199a42b 100644 --- a/yarn-project/pxe/package.local.json +++ b/yarn-project/pxe/package.local.json @@ -1,7 +1,7 @@ { - "scripts": { - "build": "yarn clean && yarn generate:package_info && tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts", - "generate:package_info": "node ./scripts/generate_package_info.js" - } -} \ No newline at end of file + "scripts": { + "build": "yarn clean && yarn generate:package_info && tsc -b", + "clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts", + "generate:package_info": "node ./scripts/generate_package_info.js" + } +} diff --git a/yarn-project/pxe/scripts/generate_package_info.js b/yarn-project/pxe/scripts/generate_package_info.js index 2b0f2e8212f..57c9801b02d 100644 --- a/yarn-project/pxe/scripts/generate_package_info.js +++ b/yarn-project/pxe/scripts/generate_package_info.js @@ -6,9 +6,10 @@ const currentDir = dirname(fileURLToPath(import.meta.url)); const { version, name } = JSON.parse(readFileSync(join(currentDir, '../package.json'))); -writeFileSync(join(currentDir, '../src/config/package_info.ts'), -`export function getPackageInfo() { +writeFileSync( + join(currentDir, '../src/config/package_info.ts'), + `export function getPackageInfo() { return { version: '${version}', name: '${name}' }; } -`); - +`, +); diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index c356bb98de7..866d2df92c7 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -191,10 +191,7 @@ export class KVPxeDatabase implements PxeDatabase { await this.addNotes([note], scope); } - async addNotes( - incomingNotes: IncomingNoteDao[], - scope: AztecAddress = AztecAddress.ZERO, - ): Promise { + async addNotes(incomingNotes: IncomingNoteDao[], scope: AztecAddress = AztecAddress.ZERO): Promise { if (!(await this.#scopes.hasAsync(scope.toString()))) { await this.#addScope(scope); } From 6d1ddf189f37745f7e1da426bf403e1b722c355a Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 18:01:35 +0000 Subject: [PATCH 14/29] nargo fmt --- noir-projects/aztec-nr/aztec/src/context/private_context.nr | 5 ++++- .../aztec/src/encrypted_logs/encrypted_note_emission.nr | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 37c6b4ad3f8..7f269f84823 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -146,7 +146,10 @@ impl PrivateContext { // debug_log("And just to make doubly sure, here is the context after pushing:"); // WARNING: if you delete this debug_log_format line, some tests fail. Be safe out there. - debug_log_format("\n\nMIKE context note hash values after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value)); + debug_log_format( + "\n\nMIKE context note hash values after pushing: {0}", + self.note_hashes.storage().map(|nh: NoteHash| nh.value), + ); // debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); // debug_log_format("\n\nMIKE - if you see a value here, the note hash is definitely in the context. self.note_hashes.storage()[0].value: {0}", [self.note_hashes.storage()[0].value]); diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 4ddcf3e0c6a..17d52927b04 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -28,7 +28,10 @@ where // [note_hash_counter as Field, storage_slot], // ); - debug_log_format("\n\nMIKE context note hash values: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.value)); + debug_log_format( + "\n\nMIKE context note hash values: {0}", + context.note_hashes.storage().map(|nh: NoteHash| nh.value), + ); // debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); // TODO(#8589): use typesystem to skip this check when not needed From 99511b7b98d762fff53e6c5c9f30f6b98ad966ad Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 20:23:34 +0000 Subject: [PATCH 15/29] handle debug symbols error --- yarn-project/foundation/src/abi/abi.ts | 50 ++++++++++++++++---------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/yarn-project/foundation/src/abi/abi.ts b/yarn-project/foundation/src/abi/abi.ts index d2d8462f5a2..fed1b8091c2 100644 --- a/yarn-project/foundation/src/abi/abi.ts +++ b/yarn-project/foundation/src/abi/abi.ts @@ -3,6 +3,7 @@ import { inflate } from 'pako'; import { z } from 'zod'; import { type Fr } from '../fields/fields.js'; +import { createDebugLogger } from '../log/index.js'; import { schemas } from '../schemas/schemas.js'; import { type ZodFor } from '../schemas/types.js'; import { type FunctionSelector } from './function_selector.js'; @@ -15,6 +16,8 @@ export interface BasicValue { value: V; } +const logger = createDebugLogger('aztec:foundation:abi'); + /** An exported value. */ export type AbiValue = | BasicValue<'boolean', boolean> @@ -390,14 +393,9 @@ export function getFunctionArtifact( if (!functionArtifact) { throw new Error(`Unknown function ${functionNameOrSelector}`); } - // TODO(#10546) investigate why debugMetadata was so big, for some tests https://github.com/AztecProtocol/aztec-packages/issues/10546, and whether it even needs to be retrieved at all, here. - let debugMetadata = undefined; - try { - debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact); - } catch (err: any) { - // It's likely that the debug_symbols string is too large. - // We'll accept debugMetadata = undefined in this case. - } + + const debugMetadata = getFunctionDebugMetadata(artifact, functionArtifact); + return { ...functionArtifact, debug: debugMetadata }; } @@ -411,18 +409,32 @@ export function getFunctionDebugMetadata( contractArtifact: ContractArtifact, functionArtifact: FunctionArtifact, ): FunctionDebugMetadata | undefined { - if (functionArtifact.debugSymbols && contractArtifact.fileMap) { - const programDebugSymbols = JSON.parse( - inflate(Buffer.from(functionArtifact.debugSymbols, 'base64'), { to: 'string', raw: true }), - ); - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5813) - // We only support handling debug info for the contract function entry point. - // So for now we simply index into the first debug info. - return { - debugSymbols: programDebugSymbols.debug_infos[0], - files: contractArtifact.fileMap, - }; + try { + if (functionArtifact.debugSymbols && contractArtifact.fileMap) { + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/10546) investigate why debugMetadata is so big for some tests. + const programDebugSymbols = JSON.parse( + inflate(Buffer.from(functionArtifact.debugSymbols, 'base64'), { to: 'string', raw: true }), + ); + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5813) + // We only support handling debug info for the contract function entry point. + // So for now we simply index into the first debug info. + return { + debugSymbols: programDebugSymbols.debug_infos[0], + files: contractArtifact.fileMap, + }; + } + } catch (err: any) { + if (err instanceof RangeError && err.message.includes('Invalid string length')) { + logger.warn( + `Caught RangeError: Invalid string length. This suggests the debug_symbols field of the contract ${contractArtifact.name} and function ${functionArtifact.name} is huge; too big to parse. We'll skip returning this info until this issue is resolved. Here's the error:\n${err.message}`, + ); + // We'll return undefined. + } else { + // Rethrow unexpected errors + throw err; + } } + return undefined; } From 61cd844437de489562fde8de8ed2fe043a489cf0 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 20:23:44 +0000 Subject: [PATCH 16/29] yarn format --- yarn-project/pxe/package.json | 2 +- yarn-project/pxe/package.local.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn-project/pxe/package.json b/yarn-project/pxe/package.json index 043184ef30c..5d8768902c7 100644 --- a/yarn-project/pxe/package.json +++ b/yarn-project/pxe/package.json @@ -112,4 +112,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/yarn-project/pxe/package.local.json b/yarn-project/pxe/package.local.json index dbecc6d0a45..3d8ea6f8262 100644 --- a/yarn-project/pxe/package.local.json +++ b/yarn-project/pxe/package.local.json @@ -1,7 +1,7 @@ { - "scripts": { - "build": "yarn clean && yarn generate && tsc -b", - "clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts", - "generate": "node ./scripts/generate_package_info.js" - } + "scripts": { + "build": "yarn clean && yarn generate && tsc -b", + "clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts", + "generate": "node ./scripts/generate_package_info.js" + } } From d54f55be07472265546d03880a5e6431d569c0c2 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 22:53:05 +0000 Subject: [PATCH 17/29] bump e2e block building timeout to 10 mins --- yarn-project/end-to-end/src/e2e_block_building.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 1651605d21e..053c96bda81 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -24,12 +24,15 @@ import { StatefulTestContract, StatefulTestContractArtifact } from '@aztec/noir- import { TestContract } from '@aztec/noir-contracts.js/Test'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; +import { jest } from '@jest/globals'; import 'jest-extended'; import { DUPLICATE_NULLIFIER_ERROR } from './fixtures/fixtures.js'; import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { + jest.setTimeout(10 * 60 * 1000); // 10 minutes + let pxe: PXE; let logger: DebugLogger; let owner: Wallet; From e608c51630bad75a45ef15c48fa212d9f7d6b348 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 22:54:13 +0000 Subject: [PATCH 18/29] tidy nr debug logs --- .../aztec-nr/aztec/src/context/private_context.nr | 14 ++------------ .../src/encrypted_logs/encrypted_note_emission.nr | 11 ----------- noir-projects/aztec-nr/aztec/src/note/lifecycle.nr | 5 ----- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 7f269f84823..c07a8336730 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -138,23 +138,13 @@ impl PrivateContext { } pub fn push_note_hash(&mut self, note_hash: Field) { - // debug_log_format( - // "\n\nMIKE About to push new note hash: (note_hash:{0}, counter: {1})", - // [note_hash, (self.side_effect_counter - 1) as Field], - // ); self.note_hashes.push(NoteHash { value: note_hash, counter: self.next_counter() }); - // debug_log("And just to make doubly sure, here is the context after pushing:"); - // WARNING: if you delete this debug_log_format line, some tests fail. Be safe out there. + // WARNING(https://github.com/AztecProtocol/aztec-packages/issues/10558): if you delete this debug_log_format line, some tests fail. debug_log_format( - "\n\nMIKE context note hash values after pushing: {0}", + "Context.note_hashes, after pushing new note hash: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.value), ); - - // debug_log_format("\n\nMIKE context note hash counters after pushing: {0}", self.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); - // debug_log_format("\n\nMIKE - if you see a value here, the note hash is definitely in the context. self.note_hashes.storage()[0].value: {0}", [self.note_hashes.storage()[0].value]); - // debug_log_format("\n\nMIKE And in case I can't print arrays like I'm trying, here's the [0].value element: {0}", [self.note_hashes.get(0).value]); - // debug_log_format("\n\nMIKE And in case I can't print arrays like I'm trying, here's the [0].counter element: {0}", [self.note_hashes.get(0).counter as Field]); } pub fn push_nullifier(&mut self, nullifier: Field) { diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 17d52927b04..f738c3827c5 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -23,17 +23,6 @@ where let note_hash_counter = note_header.note_hash_counter; let storage_slot = note_header.storage_slot; - // debug_log_format( - // "\n\nMIKE Looking for note: (note_hash_counter: {0}, storage_slot: {1})", - // [note_hash_counter as Field, storage_slot], - // ); - - debug_log_format( - "\n\nMIKE context note hash values: {0}", - context.note_hashes.storage().map(|nh: NoteHash| nh.value), - ); - // debug_log_format("\n\nMIKE context note hash counters: {0}", context.note_hashes.storage().map(|nh: NoteHash| nh.counter as Field)); - // TODO(#8589): use typesystem to skip this check when not needed let note_exists = context.note_hashes.storage().any(|n: NoteHash| n.counter == note_hash_counter); diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index 298c27c3343..90e8bf0a8d7 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -20,11 +20,6 @@ where let contract_address = (*context).this_address(); let note_hash_counter = context.side_effect_counter; - // debug_log_format( - // "\nMIKE Creating new note: (note_hash_counter: {0}, storage_slot: {1})", - // [note_hash_counter as Field, storage_slot], - // ); - let header = NoteHeader { contract_address, storage_slot, nonce: 0, note_hash_counter }; note.set_header(header); let note_hash = note.compute_note_hash(); From 7ee81fb87ad3c29af0fa378c3da2f0dadec9d2f3 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 22:54:32 +0000 Subject: [PATCH 19/29] yarn format --- yarn-project/ethereum/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index 0e34d8dcbf1..3300f21bba8 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -91,4 +91,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} From 035b8b9638c2b3a2711c4eceed35888813e1fc90 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 23:07:43 +0000 Subject: [PATCH 20/29] tidy --- .../l1_payload/encrypted_log_payload.test.ts | 40 ------------------- yarn-project/package.common.json | 12 ++---- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts index dd9a6aff630..93879b71d62 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts @@ -48,46 +48,6 @@ describe('EncryptedLogPayload', () => { }); }); - // MIKE Q: why is there note an "incoming" version of this test? - // it('outgoing cipher text matches Noir', () => { - // const ephSk = GrumpkinScalar.fromHighLow( - // new Fr(0x000000000000000000000000000000000f096b423017226a18461115fa8d34bbn), - // new Fr(0x00000000000000000000000000000000d0d302ee245dfaf2807e604eec4715fen), - // ); - - // const senderOvskApp = GrumpkinScalar.fromHighLow( - // new Fr(0x00000000000000000000000000000000089c6887cb1446d86c64e81afc78048bn), - // new Fr(0x0000000000000000000000000000000074d2e28c6bc5176ac02cf7c7d36a444en), - // ); - - // const ephPk = derivePublicKeyFromSecretKey(ephSk); - - // const recipient = AztecAddress.fromBigInt(0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70cn); - - // const addressPoint = recipient.toAddressPoint(); - - // const outgoingBodyCiphertext = EncryptedLogPayload.encryptOutgoingBody( - // ephSk, - // ephPk, - // recipient, - // addressPoint, - // senderOvskApp, - // ).toString('hex'); - - // expect(outgoingBodyCiphertext).toMatchInlineSnapshot( - // `"61dd35a8f238d9b8727f89621f3f56b38bc6a2a2d89effcd5ad48d3709f50692ca898124be1f115997cb2bc4cbe9b24fca46fab612bf4f2acdcc910e0d23ff8b8e42c1f0afe9b42599eb2958e834ebd5321a99e319f2a15c2d98646a1dc08365797e1f76bf5aee2b18523112c76b5307"`, - // ); - - // const byteArrayString = `[${outgoingBodyCiphertext.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))}]`; - - // // Run with AZTEC_GENERATE_TEST_DATA=1 to update noir test data - // updateInlineTestData( - // 'noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr', - // 'outgoing_body_ciphertext_from_typescript', - // byteArrayString, - // ); - // }); - it('encrypted tagged log matches Noir', () => { // All the values in this test were arbitrarily set and copied over to `payload.nr` const contract = AztecAddress.fromString('0x10f48cd9eff7ae5b209c557c70de2e657ee79166868676b787e9417e19260e04'); diff --git a/yarn-project/package.common.json b/yarn-project/package.common.json index 8fd6e79b1fd..2ae994eb719 100644 --- a/yarn-project/package.common.json +++ b/yarn-project/package.common.json @@ -10,11 +10,7 @@ "engines": { "node": ">=18" }, - "files": [ - "dest", - "src", - "!*.test.*" - ], + "files": ["dest", "src", "!*.test.*"], "devDependencies": { "@jest/globals": "^29.5.0", "@types/jest": "^29.5.0", @@ -23,9 +19,7 @@ "ts-node": "^10.9.1" }, "jest": { - "extensionsToTreatAsEsm": [ - ".ts" - ], + "extensionsToTreatAsEsm": [".ts"], "transform": { "^.+\\.tsx?$": [ "@swc/jest", @@ -57,4 +51,4 @@ "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", "rootDir": "./src" } -} \ No newline at end of file +} From 5967e0b1c61dd91830cbd3232064dca74b5f207c Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 23:17:52 +0000 Subject: [PATCH 21/29] rm unused debug log imports --- .../aztec/src/encrypted_logs/encrypted_note_emission.nr | 2 -- noir-projects/aztec-nr/aztec/src/note/lifecycle.nr | 2 -- 2 files changed, 4 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index f738c3827c5..9695a3edb66 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -1,5 +1,3 @@ -use dep::protocol_types::debug_log::{debug_log, debug_log_format}; - use crate::{ context::PrivateContext, encrypted_logs::payload::compute_private_log_payload, diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index 90e8bf0a8d7..d07e61e8b6b 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -1,5 +1,3 @@ -use dep::protocol_types::debug_log::{debug_log, debug_log_format}; - use crate::context::{PrivateContext, PublicContext}; use crate::note::{ note_emission::NoteEmission, From af9a640b601e0ab0f9c51188ec3557ec13798695 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 23:33:13 +0000 Subject: [PATCH 22/29] migration notes --- docs/docs/migration_notes.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 03c70c7934b..1618b37ac40 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -17,6 +17,29 @@ The `Header` struct has been renamed to `BlockHeader`, and the `get_header()` fa + let header = context.get_block_header_at(block_number); ``` +### Outgoing Events removed + +Previously, every event which was emitted included: +- Incoming Header (to convey the app contract address to the recipient) +- Incoming Ciphertext (to convey the note contents to the recipient) +- Outgoing Header (served as a backup, to convey the app contract address to the "outgoing viewer" - most likely the sender) +- Outgoing Ciphertext (served as a backup, encrypting the summetric key of the incoming ciphertext to the "outgoing viewer" - most likely the sender) + +The latter two have been removed from the `.emit()` function, so now only an Incoming Header and Incoming Ciphertext will be emitted. + +The interface for emitting a note has therefore changed, slightly. No more ovpk's and ovsk's need to be derived for the `.emit()` function. + +```diff +- nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, from_ovpk_m, to, from)); ++ nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, to, from)); +``` + +The `getOutgoingNotes` function is removed from the PXE interface. + +Further changes are planned, so that: +- Outgoing ciphertexts (or any kind of abstract ciphertext) can be emitted by a contract, and on the other side discovered and then processed by the contract. +- Headers will be removed, due to the new tagging scheme. + ## 0.66 ### DEBUG env var is removed From 9eb091c35eabce6005ddea2dff70272a048803e6 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Mon, 9 Dec 2024 23:35:28 +0000 Subject: [PATCH 23/29] fix --- yarn-project/foundation/src/abi/abi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/foundation/src/abi/abi.ts b/yarn-project/foundation/src/abi/abi.ts index fed1b8091c2..9423dde8dca 100644 --- a/yarn-project/foundation/src/abi/abi.ts +++ b/yarn-project/foundation/src/abi/abi.ts @@ -3,7 +3,7 @@ import { inflate } from 'pako'; import { z } from 'zod'; import { type Fr } from '../fields/fields.js'; -import { createDebugLogger } from '../log/index.js'; +import { createLogger } from '../log/index.js'; import { schemas } from '../schemas/schemas.js'; import { type ZodFor } from '../schemas/types.js'; import { type FunctionSelector } from './function_selector.js'; @@ -16,7 +16,7 @@ export interface BasicValue { value: V; } -const logger = createDebugLogger('aztec:foundation:abi'); +const logger = createLogger('aztec:foundation:abi'); /** An exported value. */ export type AbiValue = From dd40f21d21d7e0e77df74523828b750a74614cc6 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Tue, 10 Dec 2024 08:18:59 +0000 Subject: [PATCH 24/29] up settimeout --- yarn-project/end-to-end/src/e2e_block_building.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 004d902bb8f..38ff8cce2e1 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -31,7 +31,7 @@ import { DUPLICATE_NULLIFIER_ERROR } from './fixtures/fixtures.js'; import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { - jest.setTimeout(10 * 60 * 1000); // 10 minutes + jest.setTimeout(20 * 60 * 1000); // 20 minutes let pxe: PXE; let logger: Logger; From 8fe71021979e924a9eb9e0b4a4e3db7780339c25 Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Tue, 10 Dec 2024 14:58:42 +0000 Subject: [PATCH 25/29] Update yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Beneš --- .../circuit-types/src/logs/l1_payload/encrypted_log_payload.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts index cde665e1747..1b17fc0552f 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts @@ -18,7 +18,7 @@ import { decrypt, encrypt } from './encryption_util.js'; const ENCRYPTED_PAYLOAD_SIZE_IN_BYTES = (PRIVATE_LOG_SIZE_IN_FIELDS - 1) * 31; -// The incoming header is 48 bytes../shared_secret_derivation.js +// The incoming header is 48 bytes // 32 bytes for the address, and 16 bytes padding to follow PKCS#7 const HEADER_SIZE = 48; From 8bcd9441bbabc449a25047fdc1875de94c3bd777 Mon Sep 17 00:00:00 2001 From: Michael Connor Date: Tue, 10 Dec 2024 14:58:51 +0000 Subject: [PATCH 26/29] Update noir-projects/aztec-nr/aztec/src/context/private_context.nr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Beneš --- noir-projects/aztec-nr/aztec/src/context/private_context.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index c07a8336730..061ba0d64e1 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::debug_log::{debug_log, debug_log_format}; +use dep::protocol_types::debug_log::debug_log_format; use crate::{ context::{inputs::PrivateContextInputs, packed_returns::PackedReturns}, From 691064c8f515b0b06c33cb78fc349e603dd65784 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Tue, 10 Dec 2024 15:01:47 +0000 Subject: [PATCH 27/29] extra migration note --- docs/docs/migration_notes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index 1618b37ac40..bd8c4a622d6 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -25,9 +25,9 @@ Previously, every event which was emitted included: - Outgoing Header (served as a backup, to convey the app contract address to the "outgoing viewer" - most likely the sender) - Outgoing Ciphertext (served as a backup, encrypting the summetric key of the incoming ciphertext to the "outgoing viewer" - most likely the sender) -The latter two have been removed from the `.emit()` function, so now only an Incoming Header and Incoming Ciphertext will be emitted. +The latter two have been removed from the `.emit()` functions, so now only an Incoming Header and Incoming Ciphertext will be emitted. -The interface for emitting a note has therefore changed, slightly. No more ovpk's and ovsk's need to be derived for the `.emit()` function. +The interface for emitting a note has therefore changed, slightly. No more ovpk's need to be derived and passed into `.emit()` functions. ```diff - nfts.at(to).insert(&mut new_note).emit(encode_and_encrypt_note(&mut context, from_ovpk_m, to, from)); @@ -36,6 +36,8 @@ The interface for emitting a note has therefore changed, slightly. No more ovpk' The `getOutgoingNotes` function is removed from the PXE interface. +Some aztec.nr library methods' arguments are simplified to remove an `outgoing_viewer` parameter. E.g. `ValueNote::increment`, `ValueNote::decrement`, `ValueNote::decrement_by_at_most`, `EasyPrivateUint::add`, `EasyPrivateUint::sub`. + Further changes are planned, so that: - Outgoing ciphertexts (or any kind of abstract ciphertext) can be emitted by a contract, and on the other side discovered and then processed by the contract. - Headers will be removed, due to the new tagging scheme. From ea5fff495c81a0efc16e6ab5593d8359f2a9b038 Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Tue, 10 Dec 2024 15:05:31 +0000 Subject: [PATCH 28/29] impl review comments --- .../contracts/pending_note_hashes_contract/src/main.nr | 5 ----- ...h_just_one_contract.sh => bootstrap_just_one_contract.sh} | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) rename noir-projects/noir-contracts/scripts/{bootstraph_just_one_contract.sh => bootstrap_just_one_contract.sh} (95%) diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index 86ad8ea31e9..557b5d26849 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -71,11 +71,6 @@ contract PendingNoteHashes { 0 } - // Dummy nested/inner function (to pass a function which does nothing) - // QUESTION: can this be removed? I can't `dummy(` being used anywhere in typescript-land. - #[private] - fn dummy(amount: Field, owner: AztecAddress, sender: AztecAddress) {} - // Nested/inner function to create and insert a note #[private] fn insert_note(amount: Field, owner: AztecAddress, sender: AztecAddress) { diff --git a/noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh b/noir-projects/noir-contracts/scripts/bootstrap_just_one_contract.sh similarity index 95% rename from noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh rename to noir-projects/noir-contracts/scripts/bootstrap_just_one_contract.sh index cb803d6294d..7fbe33fcfcc 100755 --- a/noir-projects/noir-contracts/scripts/bootstraph_just_one_contract.sh +++ b/noir-projects/noir-contracts/scripts/bootstrap_just_one_contract.sh @@ -4,7 +4,7 @@ set -eu cd "$(dirname "$0")" # Call example: -# `./scripts/bootstraph_just_one_contract.sh nft_contract NFT` +# `./scripts/bootstrap_just_one_contract.sh nft_contract NFT` # Check if the filename argument is provided if [ "$#" -lt 2 ]; then From b9277a1b5dce91f623674bedea775212cb54401f Mon Sep 17 00:00:00 2001 From: iAmMichaelConnor Date: Tue, 10 Dec 2024 15:42:30 +0000 Subject: [PATCH 29/29] revert removal of dummy fn, as it did break something, and it unrelated to the goals of t his PR --- .../contracts/pending_note_hashes_contract/src/main.nr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index 557b5d26849..6e5e9d5292b 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -71,6 +71,10 @@ contract PendingNoteHashes { 0 } + // Dummy nested/inner function (to pass a function which does nothing) + #[private] + fn dummy(amount: Field, owner: AztecAddress, sender: AztecAddress) {} + // Nested/inner function to create and insert a note #[private] fn insert_note(amount: Field, owner: AztecAddress, sender: AztecAddress) {