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 0610d13c783..bb153ec8484 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 @@ -25,7 +25,7 @@ fn compute_raw_note_log( // Number of publicly delivered values is always 0 here because `compute(...)` is only called // in the non-partial note flow. - let num_publicly_delivered_values = 0; + let num_public_values = 0; let encrypted_log: [u8; M] = compute_encrypted_note_log( contract_address, storage_slot, @@ -34,7 +34,7 @@ fn compute_raw_note_log( ivpk, recipient, note, - num_publicly_delivered_values + num_public_values ); let log_hash = sha256_to_field(encrypted_log); 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 72900c2b7d4..4764132dbc6 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -73,7 +73,7 @@ pub fn compute_encrypted_note_log( ivpk: IvpkM, recipient: AztecAddress, note: Note, - num_publicly_delivered_values: u8 + num_public_values: u8 // Number of values to be appended to the log in public (used in partial note flow). ) -> [u8; M] where Note: NoteInterface { let (eph_sk, eph_pk) = generate_ephemeral_key_pair(); @@ -87,7 +87,7 @@ pub fn compute_encrypted_note_log( let mut encrypted_bytes: [u8; M] = [0; M]; // @todo We ignore the tags for now - encrypted_bytes[64] = num_publicly_delivered_values; // TODO(#8558): This can be just a single bit if we store info about partial fields in ABI + encrypted_bytes[64] = num_public_values; // TODO(#8558): This can be just a single bit if we store info about partial fields in ABI let eph_pk_bytes = point_to_bytes(eph_pk); for i in 0..32 { encrypted_bytes[65 + i] = eph_pk_bytes[i]; @@ -109,7 +109,7 @@ pub fn compute_encrypted_note_log( // Current unoptimized size of the encrypted log // incoming_tag (32 bytes) // outgoing_tag (32 bytes) - // num_publicly_delivered_values (1 byte) + // num_public_values (1 byte) // eph_pk (32 bytes) // incoming_header (48 bytes) // outgoing_header (48 bytes) @@ -173,7 +173,7 @@ mod test { let _ = OracleMock::mock("getRandomField").returns(eph_sk); let recipient = AztecAddress::from_field(0x10ee41ee4b62703b16f61e03cb0d88c4b306a9eb4a6ceeb2aff13428541689a2); - let num_publicly_delivered_values: u8 = 0; + let num_public_values: u8 = 0; let log: [u8; 449] = compute_encrypted_note_log( contract_address, @@ -183,7 +183,7 @@ mod test { ivpk_m, recipient, note, - num_publicly_delivered_values + num_public_values ); // The following value was generated by `tagged_log.test.ts` @@ -224,7 +224,7 @@ mod test { let _ = OracleMock::mock("getRandomField").returns(eph_sk); let recipient = AztecAddress::from_field(0x10ee41ee4b62703b16f61e03cb0d88c4b306a9eb4a6ceeb2aff13428541689a2); - let num_publicly_delivered_values: u8 = 2; + let num_public_values: u8 = 2; // First we compute the encrypted log without the public values let log_without_public_values: [u8; 449] = compute_encrypted_note_log( @@ -235,7 +235,7 @@ mod test { ivpk_m, recipient, note, - num_publicly_delivered_values + num_public_values ); // Then we "append" the public values to the log by copying both the original log and the current log into a new byte array diff --git a/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts index 737b7e3479c..ed5f9f192f7 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/l1_note_payload.ts @@ -67,10 +67,10 @@ export class L1NotePayload extends L1Payload { } public encrypt(ephSk: GrumpkinScalar, recipient: AztecAddress, ivpk: PublicKey, ovKeys: KeyValidationRequest) { - // TODO(#8558): numPubliclyDeliveredValues could occupy just a single bit if we store info about partial fields + // TODO(#8558): numPublicValues could occupy just a single bit if we store info about partial fields // in the ABI // We always set the value to 0 here as we don't need partial notes encryption support in TS - const numPubliclyDeliveredValues = 0; + const numPublicValues = 0; const encryptedPayload = super._encrypt( this.contractAddress, ephSk, @@ -79,7 +79,7 @@ export class L1NotePayload extends L1Payload { ovKeys, new EncryptedNoteLogIncomingBody(this.storageSlot, this.noteTypeId, this.note), ); - return Buffer.concat([Buffer.alloc(1, numPubliclyDeliveredValues), encryptedPayload]); + return Buffer.concat([Buffer.alloc(1, numPublicValues), encryptedPayload]); } /** @@ -148,13 +148,30 @@ export class L1NotePayload extends L1Payload { ); } + /** + * Extracts the public values and the remaining ciphertext from the input buffer. + * Input byte layout: + * +-----------------------------------+ + * | Byte | Description | + * |------|----------------------------| + * | 0 | num_pub_vals | + * |------|----------------------------| + * | 1 to | Ciphertext | + * | N | (N = total_length - 1 | + * | | - num_pub_vals * 32) | + * |------|----------------------------| + * | N+1 | Public values | + * | to | (num_pub_vals * 32 bytes) | + * | end | | + * +-----------------------------------+ + */ static #getPublicValuesAndRemainingCiphertext(input: Buffer): [Fr[], Buffer] { const reader = BufferReader.asReader(input); - const numPubliclyDeliveredValues = reader.readUInt8(); + const numPublicValues = reader.readUInt8(); const remainingData = reader.readToEnd(); const publicValuesData = remainingData.subarray( - remainingData.length - numPubliclyDeliveredValues * Fr.SIZE_IN_BYTES, + remainingData.length - numPublicValues * Fr.SIZE_IN_BYTES, remainingData.length, ); if (publicValuesData.length % Fr.SIZE_IN_BYTES !== 0) {