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
13
14namespace bb::avm2::simulation {
15
16// This table needs to match with the one in pil
17// Reference: https://keccak.team/keccak_specs_summary.html#rotationOffsets
19 { 0, 36, 3, 41, 18 },
20 { 1, 44, 10, 45, 2 },
21 { 62, 6, 43, 15, 61 },
22 { 28, 55, 25, 21, 56 },
23 { 27, 20, 39, 8, 14 },
24} };
25
26// Pi permutation: state_pi[x][y] = state_rho[(x + 3*y) % 5][x]
27// This table, pi_rho_x_coords[x_pi][y_pi], stores the x-coordinate for state_rho,
28// i.e., (x_pi + 3*y_pi) % 5. The y-coordinate for state_rho is simply x_pi.
30 { 0, 3, 1, 4, 2 }, // x_pi = 0
31 { 1, 4, 2, 0, 3 }, // x_pi = 1
32 { 2, 0, 3, 1, 4 }, // x_pi = 2
33 { 3, 1, 4, 2, 0 }, // x_pi = 3
34 { 4, 2, 0, 3, 1 }, // x_pi = 4
35} };
36
37// Round constants
38// Reference: https://keccak.team/keccak_specs_summary.html#roundConstants
40 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, 0x8000000080008000, 0x000000000000808b,
41 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, 0x0000000000000088,
42 0x0000000080008009, 0x000000008000000a, 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
43 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 0x000000000000800a, 0x800000008000000a,
44 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008,
45} };
46
48 public:
49 virtual ~KeccakF1600Interface() = default;
51};
52
73
74} // namespace bb::avm2::simulation
KeccakF1600(ExecutionIdManagerInterface &execution_id_manager, EventEmitterInterface< KeccakF1600Event > &keccakf1600_emitter, BitwiseInterface &bitwise, RangeCheckInterface &range_check)
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
virtual void permutation(MemoryInterface &memory, MemoryAddress dst_addr, MemoryAddress src_addr)=0
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