Skip to main content
Version: dev

Ciphers

aes128

Given a plaintext as an array of bytes, returns the corresponding aes128 ciphertext (CBC mode). Input padding is automatically performed using PKCS#7, so that the output length is input.len() + (16 - input.len() % 16).

aes128
pub fn aes128_encrypt<let N: u32>(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -> [u8] {}
Source code: noir_stdlib/src/aes128.nr#L2-L4
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
}
info

This is a black box function. Read this section to learn more about black box functions in Noir.