Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
aes128.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Khashayar], commit: 21476601b111f046f023474465598843e4cfd8ac}
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
9#include <array>
10#include <span>
11#include <vector>
12
13#include "../../primitives/field/field.hpp"
14#include "../../primitives/witness/witness.hpp"
16
17namespace bb::stdlib::aes128 {
18
19// Constants
20constexpr uint32_t AES128_BASE = 9;
21constexpr size_t BLOCK_SIZE = 16; // AES block size in bytes
22constexpr size_t EXTENDED_KEY_LENGTH = 176; // 11 round keys × 16 bytes
23constexpr size_t NUM_ROUNDS = 10; // AES-128 has 10 rounds
24constexpr size_t COLUMN_SIZE = 4; // Bytes per column in AES state (4x4 byte matrix)
25
29template <typename Builder>
33
37template <typename Builder>
39 const stdlib::field_t<Builder>& block_data);
40
44template <typename Builder>
46 std::span<stdlib::field_t<Builder>, BLOCK_SIZE> sparse_bytes);
47
48} // namespace bb::stdlib::aes128
constexpr size_t NUM_ROUNDS
Definition aes128.hpp:23
constexpr uint32_t AES128_BASE
Definition aes128.hpp:20
constexpr size_t BLOCK_SIZE
Definition aes128.hpp:21
std::array< field_t< Builder >, 16 > convert_into_sparse_bytes(Builder *ctx, const field_t< Builder > &block_data)
Converts a 128-bit block into 16 sparse-form bytes via AES_INPUT plookup table.
Definition aes128.cpp:41
field_t< Builder > convert_from_sparse_bytes(Builder *ctx, block_span< Builder > sparse_bytes)
Definition aes128.cpp:57
constexpr size_t COLUMN_SIZE
Definition aes128.hpp:24
constexpr size_t EXTENDED_KEY_LENGTH
Definition aes128.hpp:22
std::vector< field_t< Builder > > encrypt_buffer_cbc(const std::vector< field_t< Builder > > &input, const field_t< Builder > &iv, const field_t< Builder > &key)
Main public interface: AES-128 CBC encryption.
Definition aes128.cpp:353
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13