Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mov.test.cpp
Go to the documentation of this file.
1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
3
4#include <cstdint>
5
12
13namespace bb::avm2::constraining {
14namespace {
15
16using tracegen::TestTraceContainer;
18using C = Column;
20
21TEST(MovConstrainingTest, MovFF)
22{
23 TestTraceContainer trace({
24 { { C::precomputed_first_row, 1 } },
25 {
26 { C::execution_sel, 1 },
27 { C::execution_sel_execute_mov, 1 },
28 { C::execution_register_0_, FF::modulus_minus_two },
29 { C::execution_register_1_, FF::modulus_minus_two },
30 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::FF) },
31 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::FF) },
32 },
33 });
34
35 check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE, execution::SR_MOV_SAME_TAG);
36}
37
38class MovAnyTagTest : public ::testing::TestWithParam<MemoryTag> {};
39
40TEST_P(MovAnyTagTest, MovAnyTag)
41{
42 const auto tag = GetParam();
43 TestTraceContainer trace({
44 { { C::precomputed_first_row, 1 } },
45 {
46 { C::execution_sel, 1 },
47 { C::execution_sel_execute_mov, 1 },
48 { C::execution_register_0_, 1 },
49 { C::execution_register_1_, 1 },
50 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(tag) },
51 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(tag) },
52 },
53 });
54
55 check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE, execution::SR_MOV_SAME_TAG);
56}
57
59 MovConstrainingTest,
60 MovAnyTagTest,
61 ::testing::Values(
63
64TEST(MovConstrainingTest, NegativeMovDifferentTag)
65{
66 TestTraceContainer trace({
67 { { C::precomputed_first_row, 1 } },
68 {
69 { C::execution_sel, 1 },
70 { C::execution_sel_execute_mov, 1 },
71 { C::execution_register_0_, 17 },
72 { C::execution_register_1_, 17 },
73 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::U8) },
74 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::U16) },
75 },
76 });
77
78 EXPECT_THROW_WITH_MESSAGE(check_relation<execution>(trace, execution::SR_MOV_SAME_TAG),
80}
81
82TEST(MovConstrainingTest, NegativeMovDifferentValue)
83{
84 TestTraceContainer trace({
85 { { C::precomputed_first_row, 1 } },
86 {
87 { C::execution_sel, 1 },
88 { C::execution_sel_execute_mov, 1 },
89 { C::execution_register_0_, 17 },
90 { C::execution_register_1_, 18 },
91 { C::execution_mem_tag_reg_0_, static_cast<uint8_t>(MemoryTag::U32) },
92 { C::execution_mem_tag_reg_1_, static_cast<uint8_t>(MemoryTag::U32) },
93 },
94 });
95
96 EXPECT_THROW_WITH_MESSAGE(check_relation<execution>(trace, execution::SR_MOV_SAME_VALUE),
98}
99
100} // namespace
101} // namespace bb::avm2::constraining
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
Definition assert.hpp:224
INSTANTIATE_TEST_SUITE_P(All, KernelIOTamperingTests, testing::Values(KernelIOField::PAIRING_INPUTS, KernelIOField::ACCUMULATOR_HASH, KernelIOField::KERNEL_RETURN_DATA, KernelIOField::APP_RETURN_DATA, KernelIOField::ECC_OP_HASH), [](const testing::TestParamInfo< KernelIOField > &info) { switch(info.param) { case KernelIOField::PAIRING_INPUTS:return "PairingInputs";case KernelIOField::ACCUMULATOR_HASH:return "AccumulatorHash";case KernelIOField::KERNEL_RETURN_DATA:return "KernelReturnData";case KernelIOField::APP_RETURN_DATA:return "AppReturnData";case KernelIOField::ECC_OP_HASH:return "EccOpHash";} return "Unknown";})
TEST_P(KernelIOTamperingTests, CausesVerificationFailure)
static constexpr size_t SR_MOV_SAME_TAG
Definition execution.hpp:58
static std::string get_subrelation_label(size_t index)
Definition execution.hpp:80
static constexpr size_t SR_MOV_SAME_VALUE
Definition execution.hpp:57
TestTraceContainer trace
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
static constexpr uint256_t modulus_minus_two
NiceMock< MockExecution > execution