Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
verifier.test.cpp
Go to the documentation of this file.
6
7#include <gtest/gtest.h>
8
10
11class AvmVerifierTests : public ::testing::Test {
12 public:
15
17
18 // Helper function to create and verify native proof
25
26 // Helper function to create proof.
28 {
29 auto [trace, public_inputs] = testing::get_minimal_trace_with_pi();
30
31 Prover prover;
32 auto public_inputs_cols = public_inputs.to_columns();
33 const auto [proof, vk_data] = prover.prove(std::move(trace));
34 const auto verification_key = prover.create_verification_key(vk_data);
35
36 return { proof, verification_key, public_inputs_cols };
37 }
38};
39
40TEST_F(AvmVerifierTests, GoodPublicInputs)
41{
43 GTEST_SKIP() << "Skipping slow test";
44 }
45
46 NativeProofResult proof_result = create_proof_and_vk();
47 auto [proof, verification_key, public_inputs_cols] = proof_result;
48
49 Verifier verifier(verification_key);
50
51 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
52
53 ASSERT_TRUE(verified) << "native proof verification failed";
54}
55
56TEST_F(AvmVerifierTests, NegativeBadPublicInputs)
57{
59 GTEST_SKIP() << "Skipping slow test";
60 }
61
62 NativeProofResult proof_result = create_proof_and_vk();
63 auto [proof, verification_key, public_inputs_cols] = proof_result;
64 auto verify_with_corrupt_pi_col = [&](size_t col_idx) {
65 public_inputs_cols[col_idx][5] += FF::one();
66 Verifier verifier(verification_key);
67 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
68 ASSERT_FALSE(verified)
69 << "native proof verification succeeded, but should have failed due to corruption of public inputs col "
70 << col_idx;
71 public_inputs_cols[col_idx][5] -= FF::one(); // reset
72 };
73 for (size_t col_idx = 0; col_idx < 4; col_idx++) {
74 verify_with_corrupt_pi_col(col_idx);
75 }
76 Verifier verifier(verification_key);
77 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
78 ASSERT_TRUE(verified) << "native proof verification failed, but should have succeeded";
79}
80} // namespace bb::avm2::constraining
std::pair< Proof, VkData > prove(tracegen::TraceContainer &&trace)
static std::shared_ptr< AvmVerifier::VerificationKey > create_verification_key(const VkData &vk_data)
static NativeProofResult create_proof_and_vk()
TestTraceContainer trace
TEST_F(AvmRecursiveTests, GoblinRecursion)
A test of the Goblinized AVM recursive verifier.
bool skip_slow_tests()
Check if slow tests should be skipped.
Definition fixtures.cpp:199
std::pair< tracegen::TraceContainer, PublicInputs > get_minimal_trace_with_pi()
Definition fixtures.cpp:183
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::shared_ptr< AvmVerificationKey > verification_key