Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 30, 2024
1 parent 909ecf4 commit 4435b30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub fn encode_and_encrypt_note<Note, let N: u32>(
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?
sender: AztecAddress,
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
where
Expand All @@ -86,6 +87,7 @@ pub fn encode_and_encrypt_note_unconstrained<Note, let N: u32>(
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?
sender: AztecAddress,
) -> fn[(&mut PrivateContext, OvpkM, AztecAddress, AztecAddress)](NoteEmission<Note>) -> ()
where
Expand Down
19 changes: 15 additions & 4 deletions noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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},
utils::point::point_to_bytes,
};
use protocol_types::public_keys::AddressPoint;
use protocol_types::hash::poseidon2_hash;

fn compute_private_log_payload<let P: u32, let M: u32>(
contract_address: AztecAddress,
Expand All @@ -39,7 +39,17 @@ fn compute_private_log_payload<let P: u32, let M: u32>(
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)
};

let tag = poseidon2_hash([tagging_secret.secret, recipient.to_field(), tagging_secret.index as Field]);
let tag_bytes = 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);
Expand Down Expand Up @@ -215,6 +225,7 @@ mod test {
contract_address,
ovsk_app,
ovpk_m,
sender,
recipient,
sender,
plaintext,
Expand Down

0 comments on commit 4435b30

Please sign in to comment.