aztec-nr - noir_aztec::messages::encryption::log_encryption

Trait LogEncryption

pub trait LogEncryption {
    // Required methods
    pub fn encrypt_log<let PlaintextLen: u32>(
        plaintext: [Field; PlaintextLen],
        recipient: AztecAddress,
    ) -> [Field; 17];
    pub unconstrained fn decrypt_log(
        ciphertext: BoundedVec<Field, 17>,
        recipient: AztecAddress,
    ) -> BoundedVec<Field, 14>;
}

Trait for encrypting and decrypting private logs in the Aztec protocol.

This trait defines the interface for encrypting plaintext data into private logs that can be emitted on-chain or delivered out-of-band, and decrypting those logs back into their original plaintext.

Type Parameters

Note on privacy sets

To preserve privacy, encrypt_log returns a fixed-length array ensuring all log types are indistinguishable on-chain. Implementations of this trait must handle padding the encrypted log to match this standardized length.

Required methods

pub fn encrypt_log<let PlaintextLen: u32>( plaintext: [Field; PlaintextLen], recipient: AztecAddress, ) -> [Field; 17]

Encrypts a plaintext field array into a private log that can be emitted on-chain.

Arguments

  • plaintext - Array of Field elements to encrypt
  • recipient - Aztec address of intended recipient who can decrypt the log

Returns

Fixed-size array of encrypted Field elements representing the private log

pub unconstrained fn decrypt_log( ciphertext: BoundedVec<Field, 17>, recipient: AztecAddress, ) -> BoundedVec<Field, 14>

Decrypts a private log back into its original plaintext fields. This function is unconstrained since decryption happens when processing logs in an unconstrained context.

Arguments

  • ciphertext - Bounded vector containing the encrypted log fields
  • recipient - Aztec address of the recipient who can decrypt

Returns

Bounded vector containing the decrypted plaintext fields

Note on use of BoundedVec

BoundedVec is required since the log length cannot be determined at compile time. This is because the Contract::process_log function is designed to work with all the private logs, emitted by a given contract and not just by 1 log type.

Implementors

impl LogEncryption for AES128