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 53e44a130952..81cbaf1991ac 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 @@ -91,7 +91,7 @@ pub fn encode_and_encrypt_note_unconstrained( } } -pub fn encrypt_and_emit_log_of_partial( +pub fn encrypt_and_emit_partial_log( context: &mut PrivateContext, log_plaintext: [u8; M], ovpk: OvpkM, 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 0c3f06ccdf9f..e12ce662bddf 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr @@ -317,7 +317,7 @@ comptime fn generate_partial_payload( let new_generators = new_generators_list.push_back(quote { aztec::generators::G_slot }).join(quote {,}); let new_scalars = new_scalars_list.push_back(quote { std::hash::from_field_unsafe(storage_slot) }).join(quote {,}); - let buffer_length = indexed_fixed_fields.len() * 32 + 64; + let log_plaintext_length = indexed_fixed_fields.len() * 32 + 64; // Now we compute serialization of the fixed fields. We do that by passing the whole note struct // to the flatten_to_fields function but we omit the NoteHeader and the nullable fields. @@ -334,15 +334,15 @@ comptime fn generate_partial_payload( let serialized_fields = fields.join(quote {,}); // indexed_fixed_fields has preserved order so we can used to serialize the note to log - let partial_note_buffer = quote { - let mut buffer: [u8; $buffer_length] = [0; $buffer_length]; + let partial_note_log_plaintext = quote { + let mut log_plaintext: [u8; $log_plaintext_length] = [0; $log_plaintext_length]; let storage_slot_bytes: [u8; 32] = storage_slot.to_be_bytes(); let note_type_id_bytes: [u8; 32] = $name::get_note_type_id().to_be_bytes(); for i in 0..32 { - buffer[i] = storage_slot_bytes[i]; - buffer[32 + i] = note_type_id_bytes[i]; + log_plaintext[i] = storage_slot_bytes[i]; + log_plaintext[32 + i] = note_type_id_bytes[i]; } $aux_vars_for_serialization @@ -351,14 +351,14 @@ comptime fn generate_partial_payload( for i in 0..serialized_note.len() { let bytes: [u8; 32] = serialized_note[i].to_be_bytes(); for j in 0..32 { - buffer[64 + i * 32 + j] = bytes[j]; + log_plaintext[64 + i * 32 + j] = bytes[j]; } } }; (quote { struct $partial_payload_name { - buffer: [u8; $buffer_length], + log_plaintext: [u8; $log_plaintext_length], hiding_point: $hiding_point_name } @@ -370,10 +370,10 @@ comptime fn generate_partial_payload( [$new_scalars] ); let hiding_point = $hiding_point_name::empty().from_point(point); - $partial_note_buffer + $partial_note_log_plaintext $partial_payload_name { - buffer, + log_plaintext, hiding_point } } @@ -381,7 +381,7 @@ comptime fn generate_partial_payload( impl aztec::protocol_types::traits::Empty for $partial_payload_name { fn empty() -> Self { - Self { buffer: [0; $buffer_length], hiding_point: $hiding_point_name::empty() } + Self { log_plaintext: [0; $log_plaintext_length], hiding_point: $hiding_point_name::empty() } } } }, partial_payload_name) 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 86efadd8ef2e..bc4214ccafc3 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -10,7 +10,7 @@ contract NFT { use dep::compressed_string::FieldCompressedString; use dep::aztec::{ prelude::{NoteGetterOptions, NoteViewerOptions, Map, PublicMutable, SharedImmutable, PrivateSet, AztecAddress}, - encrypted_logs::{encrypted_note_emission::{encode_and_encrypt_note, encrypt_and_emit_log_of_partial}}, + encrypted_logs::{encrypted_note_emission::{encode_and_encrypt_note, encrypt_and_emit_partial_log}}, hash::pedersen_hash, keys::getters::get_public_keys, note::constants::MAX_NOTES_PER_PAGE, protocol_types::traits::is_empty, utils::comparison::Comparator, protocol_types::{point::Point, traits::Serialize}, @@ -147,16 +147,17 @@ contract NFT { transient_storage_slot_randomness: Field ) { let to_keys = get_public_keys(to); - // We create a partial NFT note hiding point with unpopulated/zero token id for 'to' let to_npk_m_hash = to_keys.npk_m.hash(); let to_note_slot = storage.private_nfts.at(to).storage_slot; + + // We create a partial NFT note hiding point with unpopulated/zero token id for 'to' let note_partial_payload = NFTNote::partial_payload().new(to_npk_m_hash, note_randomness, to_note_slot); // `from` cannot receive any logs here as that would leak information of who is the note recipient. For this // reason we encrypt outgoing to `to`. - encrypt_and_emit_log_of_partial( + encrypt_and_emit_partial_log( &mut context, - note_partial_payload.buffer, + note_partial_payload.log_plaintext, to_keys.ovpk_m, to_keys.ivpk_m, to