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 const auto [proof, vk_data] = prover.prove(std::move(trace));
33 const auto verification_key = prover.create_verification_key(vk_data);
34
35 auto public_inputs_cols = public_inputs.to_columns();
36 return { proof, verification_key, public_inputs_cols };
37 }
38};
39
40TEST_F(AvmVerifierTests, GoodPublicInputs)
41{
42 NativeProofResult proof_result = create_proof_and_vk();
43 auto [proof, verification_key, public_inputs_cols] = proof_result;
44
45 Verifier verifier(verification_key);
46
47 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
48
49 ASSERT_TRUE(verified) << "native proof verification failed";
50}
51
52TEST_F(AvmVerifierTests, NegativeBadPublicInputs)
53{
54 NativeProofResult proof_result = create_proof_and_vk();
55 auto [proof, verification_key, public_inputs_cols] = proof_result;
56 auto verify_with_corrupt_pi_col = [&](size_t col_idx) {
57 public_inputs_cols[col_idx][5] += FF::one();
58 Verifier verifier(verification_key);
59 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
60 ASSERT_FALSE(verified)
61 << "native proof verification succeeded, but should have failed due to corruption of public inputs col "
62 << col_idx;
63 public_inputs_cols[col_idx][5] -= FF::one(); // reset
64 };
65 for (size_t col_idx = 0; col_idx < 4; col_idx++) {
66 verify_with_corrupt_pi_col(col_idx);
67 }
68 Verifier verifier(verification_key);
69 const bool verified = verifier.verify_proof(proof, public_inputs_cols);
70 ASSERT_TRUE(verified) << "native proof verification failed, but should have succeeded";
71}
72} // 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.
std::pair< tracegen::TraceContainer, PublicInputs > get_minimal_trace_with_pi()
Definition fixtures.cpp:182
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