aztec-nr - noir_aztec::oracle::aes128_decrypt

Function try_aes128_decrypt

pub unconstrained fn try_aes128_decrypt<let N: u32>(
    ciphertext: BoundedVec<u8, N>,
    iv: [u8; 16],
    sym_key: [u8; 16],
) -> Option<BoundedVec<u8, N>>

Attempts to decrypt a ciphertext using AES128.

Returns Option::some(plaintext) on success, or Option::none() if decryption fails (e.g. due to malformed ciphertext). Note that decryption with the wrong key will still return Some with garbage data, it's up to the calling function to verify correctness (e.g. via a MAC check).

Note that we accept ciphertext as a BoundedVec, not as an array. This is because this function is typically used when processing logs and at that point we don't have comptime information about the length of the ciphertext as the log is not specific to any individual note.