Skip to content

Commit 90d3390

Browse files
author
sklppy88
committed
init
1 parent 9ffbb33 commit 90d3390

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

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

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
use dep::protocol_types::{
2-
address::AztecAddress,
3-
constants::{GENERATOR_INDEX__SYMMETRIC_KEY, PRIVATE_LOG_SIZE_IN_BYTES},
4-
hash::poseidon2_hash_with_separator,
5-
point::Point,
6-
public_keys::OvpkM,
7-
scalar::Scalar,
2+
address::AztecAddress, constants::GENERATOR_INDEX__SYMMETRIC_KEY, public_keys::AddressPoint,
3+
hash::poseidon2_hash_with_separator, point::Point, public_keys::OvpkM, scalar::Scalar,
84
};
95
use std::{
106
aes128::aes128_encrypt, embedded_curve_ops::fixed_base_scalar_mul as derive_public_key,
@@ -13,10 +9,10 @@ use std::{
139

1410
use crate::{
1511
encrypted_logs::header::EncryptedLogHeader,
16-
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}},
1713
utils::point::point_to_bytes,
1814
};
19-
use protocol_types::public_keys::AddressPoint;
15+
use protocol_types::hash::poseidon2_hash;
2016

2117
pub comptime global PRIVATE_LOG_OVERHEAD_IN_BYTES: u32 = 304;
2218

@@ -125,8 +121,22 @@ fn compute_encrypted_log<let P: u32, let M: u32>(
125121
let mut encrypted_bytes = [0; M];
126122
let mut offset = 0;
127123

128-
// @todo We ignore the tags for now
129-
// incoming_tag
124+
let mut encrypted_bytes: [u8; M] = [0; M];
125+
126+
let tagging_secret = unsafe {
127+
get_app_tagging_secret(sender, recipient)
128+
};
129+
130+
unsafe {
131+
increment_app_tagging_secret(sender, recipient);
132+
};
133+
134+
let tag = tagging_secret.compute_tag();
135+
let tag_bytes: [u8; 32] = tag.to_be_bytes();
136+
137+
for i in 0..32 {
138+
encrypted_bytes[offset + i] = tag_bytes[i];
139+
}
130140
offset += 32;
131141

132142
// eph_pk

noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::traits::{Deserialize, Serialize};
2-
use super::address::aztec_address::AztecAddress;
2+
use super::{address::aztec_address::AztecAddress, hash::poseidon2_hash};
33
use std::meta::derive;
44

55
pub global INDEXED_TAGGING_SECRET_LENGTH: u32 = 3;
@@ -10,3 +10,9 @@ pub struct IndexedTaggingSecret {
1010
recipient: AztecAddress,
1111
index: u32,
1212
}
13+
14+
impl IndexedTaggingSecret {
15+
pub fn compute_tag(self) -> Field {
16+
poseidon2_hash([self.secret, self.recipient.to_field(), self.index as Field])
17+
}
18+
}

yarn-project/circuits.js/src/structs/tagging_secret.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AztecAddress } from '@aztec/foundation/aztec-address';
2+
import { poseidon2Hash } from '@aztec/foundation/crypto';
23
import { Fr } from '@aztec/foundation/fields';
34

45
export class TaggingSecret {
@@ -25,4 +26,8 @@ export class IndexedTaggingSecret extends TaggingSecret {
2526
static fromTaggingSecret(directionalSecret: TaggingSecret, index: number) {
2627
return new this(directionalSecret.secret, directionalSecret.recipient, index);
2728
}
29+
30+
computeTag() {
31+
return poseidon2Hash([this.secret, this.recipient, this.index]);
32+
}
2833
}

yarn-project/pxe/src/simulator_oracle/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ export class SimulatorOracle implements DBOracle {
333333
const logs: EncryptedL2NoteLog[] = [];
334334
while (appTaggingSecrets.length > 0) {
335335
// 2. Compute tags using the secrets, recipient and index. Obtain logs for each tag (#9380)
336-
const currentTags = appTaggingSecrets.map(({ secret, recipient, index }) =>
337-
poseidon2Hash([secret, recipient, index]),
338-
);
336+
const currentTags = appTaggingSecrets.map((taggingSecret) => taggingSecret.computeTag());
339337
const logsByTags = await this.aztecNode.getLogsByTags(currentTags);
340338
const newTaggingSecrets: IndexedTaggingSecret[] = [];
341339
logsByTags.forEach((logsByTag, index) => {

0 commit comments

Comments
 (0)