1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
25class KeccakSimulationTest :
public ::testing::Test {
27 KeccakSimulationTest()
52 for (
size_t i = 0; i < 5; i++) {
53 for (
size_t j = 0; j < 5; j++) {
54 flattened[(j * 5) + i] = state[i][j];
59TEST_F(KeccakSimulationTest, matchesReferenceImplementation)
62 { { 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 } }
68 uint64_t reference_input[25];
69 uint64_t flat_output[25];
70 flatten_state(input, reference_input);
72 for (
size_t i = 0; i < 5; i++) {
73 for (
size_t j = 0; j < 5; j++) {
81 for (
size_t i = 0; i < 5; i++) {
82 for (
size_t j = 0; j < 5; j++) {
85 output[i][j] = val.as<uint64_t>();
89 flatten_state(output, flat_output);
92 EXPECT_THAT(reference_input, testing::ElementsAreArray(flat_output));
98TEST_F(KeccakSimulationTest, tagError)
106 for (
size_t i = 0; i < 5; i++) {
107 for (
size_t j = 0; j < 5; j++) {
118 format(
"Read slice tag invalid - addr: ", src_addr_wrong_tag,
" tag: ",
static_cast<uint32_t
>(wrong_tag)));
121TEST_F(KeccakSimulationTest, srcSliceOutOfBounds)
129TEST_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
testing::StrictMock< MockGreaterThan > greater_than
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
std::array< std::array< uint64_t, 5 >, 5 > KeccakF1600State
TEST_F(IPATest, ChallengesAreZero)
FieldGreaterThan field_gt
NoopEventEmitter< GreaterThanEvent > greater_than_event_emitter
NoopEventEmitter< FieldGreaterThanEvent > field_gt_event_emitter
NoopEventEmitter< BitwiseEvent > bitwise_event_emitter
NoopEventEmitter< KeccakF1600Event > keccak_event_emitter