Skip to content

Commit 90b9f43

Browse files
author
sklppy88
committed
init
1 parent f5f9542 commit 90b9f43

File tree

1 file changed

+18
-4
lines changed
  • noir-projects/aztec-nr/aztec/src/encrypted_logs

1 file changed

+18
-4
lines changed

noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use dep::protocol_types::{
2-
address::AztecAddress, constants::GENERATOR_INDEX__SYMMETRIC_KEY,
2+
address::AztecAddress, constants::GENERATOR_INDEX__SYMMETRIC_KEY, public_keys::AddressPoint,
33
hash::poseidon2_hash_with_separator, point::Point, public_keys::OvpkM, scalar::Scalar,
44
};
55
use std::{
@@ -9,10 +9,10 @@ use std::{
99

1010
use crate::{
1111
encrypted_logs::header::EncryptedLogHeader,
12-
keys::point_to_symmetric_key::point_to_symmetric_key, oracle::random::random,
12+
keys::point_to_symmetric_key::point_to_symmetric_key, oracle::{random::random, notes::{get_app_tagging_secret, increment_app_tagging_secret}},
1313
utils::point::point_to_bytes,
1414
};
15-
use protocol_types::public_keys::AddressPoint;
15+
use protocol_types::hash::poseidon2_hash;
1616

1717
fn compute_private_log_payload<let P: u32, let M: u32>(
1818
contract_address: AztecAddress,
@@ -39,7 +39,21 @@ fn compute_private_log_payload<let P: u32, let M: u32>(
3939
let mut offset = if include_public_values_prefix { 1 } else { 0 };
4040

4141
let mut encrypted_bytes: [u8; M] = [0; M];
42-
// @todo We ignore the tags for now
42+
43+
let tagging_secret = unsafe {
44+
get_app_tagging_secret(sender, recipient)
45+
};
46+
47+
unsafe {
48+
increment_app_tagging_secret(sender, recipient);
49+
};
50+
51+
let tag = poseidon2_hash([tagging_secret.secret, recipient.to_field(), tagging_secret.index as Field]);
52+
let tag_bytes: [u8; 32] = tag.to_be_bytes();
53+
54+
for i in 0..32 {
55+
encrypted_bytes[offset + i] = tag_bytes[i];
56+
}
4357
offset += 32;
4458

4559
let eph_pk_bytes = point_to_bytes(eph_pk);

0 commit comments

Comments
 (0)