Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
avm_fixed_vk.test.cpp
Go to the documentation of this file.
5
6#include <gtest/gtest.h>
7
9
16TEST(AvmFixedVKTests, FixedVKCommitments)
17{
19 AvmTraceGenHelper tracegen_helper;
20 auto trace = tracegen_helper.generate_precomputed_columns();
21
22 auto polynomials = compute_polynomials(trace);
23 auto proving_key = proving_key_from_polynomials(polynomials);
24
25 auto vk_computed = AvmVerifier::VerificationKey::from_proving_key(*proving_key);
26 auto vk_computed_commitments = vk_computed.get_all();
27
28 // Get the fixed VK commitments
29 auto fixed_vk_commitments = AvmFixedVKCommitments::get_all();
30
31 // Check that sizes match
32 EXPECT_EQ(vk_computed_commitments.size(), fixed_vk_commitments.size())
33 << "VK commitments size mismatch: computed has " << vk_computed_commitments.size() << " commitments, fixed has "
34 << fixed_vk_commitments.size();
35
36 // Compare each commitment
37 auto labels = vk_computed.get_labels();
38 for (size_t i = 0; i < vk_computed_commitments.size(); ++i) {
39 EXPECT_EQ(vk_computed_commitments[i], fixed_vk_commitments[i])
40 << "Mismatch at index " << i << " (label: " << labels[i] << ")";
41 }
42
43 // Uncomment to print the commitments formatted for easy copy-paste into avm_fixed_vk.hpp
44 // std::cout << "// Copy these commitments into AvmFixedVKCommitments::get_all():\n";
45 // for (size_t i = 0; i < vk_computed_commitments.size(); ++i) {
46 // const auto& commitment = vk_computed_commitments[i];
47 // if (commitment.is_point_at_infinity()) {
48 // std::cout << "Commitment::infinity()";
49 // } else {
50 // std::cout << "Commitment(uint256_t(\"" << uint256_t(commitment.x) << "\"), uint256_t(\""
51 // << uint256_t(commitment.y) << "\"))";
52 // }
53 // if (i < vk_computed_commitments.size() - 1) {
54 // std::cout << ",";
55 // }
56 // std::cout << " // " << labels[i] << "\n";
57 // }
58}
59
60} // namespace bb::avm2::constraining
static VerificationKey from_proving_key(const ProvingKey &proving_key)
Definition flavor.hpp:254
tracegen::TraceContainer generate_precomputed_columns()
static constexpr std::array< Commitment, VerificationKey::NUM_PRECOMPUTED_COMMITMENTS > get_all()
TestTraceContainer trace
AvmProver::ProverPolynomials compute_polynomials(tracegen::TraceContainer &trace)
std::shared_ptr< AvmProver::ProvingKey > proving_key_from_polynomials(AvmProver::ProverPolynomials &polynomials)
TEST(AvmFixedVKTests, FixedVKCommitments)
Test that the fixed VK commitments agree with the ones computed from precomputed columns.
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)