Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
keccakf1600.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5
15
16namespace bb::avm2::simulation {
17
18// This table needs to match with the one in pil
19// Reference: https://keccak.team/keccak_specs_summary.html#rotationOffsets
21 { 0, 36, 3, 41, 18 },
22 { 1, 44, 10, 45, 2 },
23 { 62, 6, 43, 15, 61 },
24 { 28, 55, 25, 21, 56 },
25 { 27, 20, 39, 8, 14 },
26} };
27
28// Pi permutation: state_pi[x][y] = state_rho[(x + 3*y) % 5][x]
29// This table, pi_rho_x_coords[x_pi][y_pi], stores the x-coordinate for state_rho,
30// i.e., (x_pi + 3*y_pi) % 5. The y-coordinate for state_rho is simply x_pi.
32 { 0, 3, 1, 4, 2 }, // x_pi = 0
33 { 1, 4, 2, 0, 3 }, // x_pi = 1
34 { 2, 0, 3, 1, 4 }, // x_pi = 2
35 { 3, 1, 4, 2, 0 }, // x_pi = 3
36 { 4, 2, 0, 3, 1 }, // x_pi = 4
37} };
38
39// Round constants
40// Reference: https://keccak.team/keccak_specs_summary.html#roundConstants
42 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, 0x8000000080008000, 0x000000000000808b,
43 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, 0x0000000000000088,
44 0x0000000080008009, 0x000000008000000a, 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
45 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 0x000000000000800a, 0x800000008000000a,
46 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008,
47} };
48
72
73} // namespace bb::avm2::simulation
EventEmitterInterface< KeccakF1600Event > & perm_events
void permutation(MemoryInterface &memory, MemoryAddress dst_addr, MemoryAddress src_addr) override
Permutation Keccak-f[1600] consisting in AVM_KECCAKF1600_NUM_ROUNDS (24) rounds and a state of 25 64-...
RangeCheckInterface & range_check
ExecutionIdManagerInterface & execution_id_manager
KeccakF1600(ExecutionIdManagerInterface &execution_id_manager, EventEmitterInterface< KeccakF1600Event > &keccakf1600_emitter, BitwiseInterface &bitwise, RangeCheckInterface &range_check, GreaterThanInterface &gt)
uint32_t dst_addr
constexpr std::array< std::array< uint8_t, 5 >, 5 > keccak_pi_rho_x_coords
constexpr std::array< uint64_t, 24 > keccak_round_constants
constexpr std::array< std::array< uint8_t, 5 >, 5 > keccak_rotation_len
uint32_t MemoryAddress
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13