1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
19using tracegen::KeccakF1600TraceBuilder;
20using tracegen::TestTraceContainer;
26TEST(KeccakF1600ConstrainingTest, EmptyRow)
32TEST(KeccakF1600ConstrainingTest, SinglewithSimulationAndTraceGenInteractions)
34 TestTraceContainer
trace;
41 check_all_interactions<tracegen::KeccakF1600TraceBuilder>(trace);
42 check_relation<keccakf1600_relation>(trace);
43 check_relation<keccak_memory_relation>(trace);
48TEST(KeccakF1600ConstrainingTest, MultipleWithSimulationAndTraceGenInteractions)
50 TestTraceContainer
trace;
52 constexpr size_t NUM_PERMUTATIONS = 3;
57 for (
size_t k = 0; k < NUM_PERMUTATIONS; ++k) {
59 dst_addresses.at(k) =
static_cast<MemoryAddress>((k * 200) + 1000);
64 check_all_interactions<tracegen::KeccakF1600TraceBuilder>(trace);
65 check_relation<keccakf1600_relation>(trace);
66 check_relation<keccak_memory_relation>(trace);
73TEST(KeccakF1600ConstrainingTest, TagErrorHandling)
75 TestTraceContainer
trace;
79 const uint16_t space_id = 79;
83 const size_t error_offset = 7;
88 check_all_interactions<tracegen::KeccakF1600TraceBuilder>(trace);
89 check_relation<keccakf1600_relation>(trace);
90 check_relation<keccak_memory_relation>(trace);
94TEST(KeccakF1600ConstrainingTest, SrcAddressOutOfBounds)
96 TestTraceContainer
trace;
100 const uint16_t space_id = 23;
104 check_all_interactions<tracegen::KeccakF1600TraceBuilder>(trace);
105 check_relation<keccakf1600_relation>(trace);
106 check_relation<keccak_memory_relation>(trace);
110TEST(KeccakF1600ConstrainingTest, DstAddressOutOfBounds)
112 TestTraceContainer
trace;
116 const uint16_t space_id = 23;
120 check_all_interactions<tracegen::KeccakF1600TraceBuilder>(trace);
121 check_relation<keccakf1600_relation>(trace);
122 check_relation<keccak_memory_relation>(trace);
126TEST(KeccakF1600ConstrainingTest, NegativeRoundCountAtWrite)
128 TestTraceContainer
trace = TestTraceContainer({ {
129 { C::precomputed_first_row, 1 },
132 { C::keccakf1600_sel, 1 },
133 { C::keccakf1600_sel_slice_write, 1 },
134 { C::keccakf1600_round, 23 },
138 check_relation<keccakf1600_relation>(trace, keccakf1600_relation::SR_ROUND_COUNT_AT_WRITE),
139 "ROUND_COUNT_AT_WRITE");
142 trace.
set(C::keccakf1600_round, 1, 24);
143 check_relation<keccakf1600_relation>(trace, keccakf1600_relation::SR_ROUND_COUNT_AT_WRITE);
150TEST(KeccakF1600ConstrainingTest, NegativeTraceContinuity)
152 TestTraceContainer
trace = TestTraceContainer({ {
153 { C::precomputed_first_row, 1 },
154 { C::keccakf1600_sel, 1 },
155 { C::keccakf1600_start, 1 },
158 { C::keccakf1600_sel, 1 },
161 { C::keccakf1600_sel, 0 },
169 trace.
set(C::keccakf1600_end, 1, 1);
171 check_relation<keccakf1600_relation>(trace, keccakf1600_relation::SR_TRACE_CONTINUITY);
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
#define AVM_KECCAKF1600_STATE_SIZE
#define AVM_HIGHEST_MEM_ADDRESS
void set(Column col, uint32_t row, const FF &value)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
void generate_keccak_trace(TestTraceContainer &trace, const std::vector< MemoryAddress > &dst_addresses, const std::vector< MemoryAddress > &src_addresses, uint16_t space_id)
void generate_keccak_trace_with_slice_error(TestTraceContainer &trace, MemoryAddress dst_address, MemoryAddress src_address, uint16_t space_id)
TestTraceContainer empty_trace()
void generate_keccak_trace_with_tag_error(TestTraceContainer &trace, MemoryAddress dst_address, MemoryAddress src_address, size_t error_offset, MemoryTag error_tag, uint16_t space_id)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept