1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
24class KeccakSimulationTest :
public ::testing::Test {
26 KeccakSimulationTest()
45 for (
size_t i = 0; i < 5; i++) {
46 for (
size_t j = 0; j < 5; j++) {
47 flattened[(j * 5) + i] = state[i][j];
52TEST_F(KeccakSimulationTest, matchesReferenceImplementation)
55 { { 0, 1, 2, 3, 4 }, { 5, 6, 7, 8, 9 }, { 10, 11, 12, 13, 14 }, { 15, 16, 17, 18, 19 }, { 20, 21, 22, 23, 24 } }
61 uint64_t reference_input[25];
62 uint64_t flat_output[25];
63 flatten_state(input, reference_input);
65 for (
size_t i = 0; i < 5; i++) {
66 for (
size_t j = 0; j < 5; j++) {
74 for (
size_t i = 0; i < 5; i++) {
75 for (
size_t j = 0; j < 5; j++) {
78 output[i][j] = val.as<uint64_t>();
82 flatten_state(output, flat_output);
85 EXPECT_THAT(reference_input, testing::ElementsAreArray(flat_output));
91TEST_F(KeccakSimulationTest, tagError)
99 for (
size_t i = 0; i < 5; i++) {
100 for (
size_t j = 0; j < 5; j++) {
111 format(
"Read slice tag invalid - addr: ", src_addr_wrong_tag,
" tag: ",
static_cast<uint32_t
>(wrong_tag)));
114TEST_F(KeccakSimulationTest, srcSliceOutOfBounds)
122TEST_F(KeccakSimulationTest, dstSliceOutOfBounds)
#define AVM_KECCAKF1600_STATE_SIZE
#define AVM_HIGHEST_MEM_ADDRESS
static TaggedValue from_tag_truncating(ValueTag tag, FF value)
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-...
void set(MemoryAddress index, MemoryValue value) override
const MemoryValue & get(MemoryAddress index) const override
std::string format(Args... args)
ExecutionIdManager execution_id_manager
EventEmitter< RangeCheckEvent > range_check_event_emitter
void ethash_keccakf1600(uint64_t state[25]) NOEXCEPT
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
std::array< std::array< uint64_t, 5 >, 5 > KeccakF1600State
TEST_F(IPATest, ChallengesAreZero)
NoopEventEmitter< BitwiseEvent > bitwise_event_emitter
NoopEventEmitter< KeccakF1600Event > keccak_event_emitter