From 3bd8c5132daee26e0b2d9f38ec8e748ca474b334 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Tue, 29 Oct 2024 13:39:23 +0000 Subject: [PATCH] init --- .../aztec/src/encrypted_logs/payload.nr | 22 +++++++++++++++---- .../contracts/token_contract/src/main.nr | 2 +- 2 files changed, 19 insertions(+), 5 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 8e9d0001910c..28d5810a0e9d 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{ - address::AztecAddress, constants::GENERATOR_INDEX__SYMMETRIC_KEY, + address::AztecAddress, constants::GENERATOR_INDEX__SYMMETRIC_KEY, public_keys::AddressPoint, hash::poseidon2_hash_with_separator, point::Point, public_keys::OvpkM, scalar::Scalar, }; use std::{ @@ -9,10 +9,10 @@ use std::{ use crate::{ encrypted_logs::header::EncryptedLogHeader, - keys::point_to_symmetric_key::point_to_symmetric_key, oracle::random::random, + keys::point_to_symmetric_key::point_to_symmetric_key, oracle::{random::random, notes::{get_app_tagging_secret, increment_app_tagging_secret}}, utils::point::point_to_bytes, }; -use protocol_types::public_keys::AddressPoint; +use protocol_types::hash::poseidon2_hash; fn compute_private_log_payload( contract_address: AztecAddress, @@ -39,7 +39,21 @@ fn compute_private_log_payload( let mut offset = if include_public_values_prefix { 1 } else { 0 }; let mut encrypted_bytes: [u8; M] = [0; M]; - // @todo We ignore the tags for now + + let tagging_secret = unsafe { + get_app_tagging_secret(sender, recipient) + }; + + unsafe { + increment_app_tagging_secret(tagging_secret); + }; + + let tag = poseidon2_hash([tagging_secret.secret, recipient.to_field(), tagging_secret.index as Field]); + let tag_bytes: [u8; 32] = tag.to_be_bytes(); + + for i in 0..32 { + encrypted_bytes[offset + i] = tag_bytes[i]; + } offset += 32; let eph_pk_bytes = point_to_bytes(eph_pk); 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 ad66b4db672f..5989bc9695be 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -534,7 +534,7 @@ contract Token { // 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); + let setup_log = note_setup_payload.encrypt_log(context, from_ovpk, 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