Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
stdlib_verification_key.test.cpp
Go to the documentation of this file.
11
12#include <gtest/gtest.h>
13
14using namespace bb;
15
16template <typename Flavor> class StdlibVerificationKeyTests : public ::testing::Test {
17 public:
18 using NativeFlavor = typename Flavor::NativeFlavor;
19 void set_default_pairing_points_and_ipa_claim_and_proof(typename NativeFlavor::CircuitBuilder& builder)
20 {
22 if constexpr (HasIPAAccumulator<NativeFlavor>) {
23 auto [stdlib_opening_claim, ipa_proof] =
25 stdlib_opening_claim.set_public();
26 builder.ipa_proof = ipa_proof;
27 }
28 }
29
30 protected:
32};
33
34using FlavorTypes = testing::Types<UltraRecursiveFlavor_<UltraCircuitBuilder>,
41
48{
49 using Flavor = TypeParam;
50 using NativeFlavor = typename Flavor::NativeFlavor;
51 using NativeVerificationKey = typename NativeFlavor::VerificationKey;
52 using StdlibTranscript = typename Flavor::Transcript;
53 using StdlibVerificationKey = typename Flavor::VerificationKey;
54 using OuterBuilder = typename Flavor::CircuitBuilder;
56
57 // Create random circuit to create a vk.
59 if constexpr (IsAnyOf<Flavor, TranslatorRecursiveFlavor, ECCVMRecursiveFlavor>) {
61 } else {
63 using InnerBuilder = typename NativeFlavor::CircuitBuilder;
64
65 InnerBuilder builder;
66 TestFixture::set_default_pairing_points_and_ipa_claim_and_proof(builder);
68 native_vk = std::make_shared<NativeVerificationKey>(proving_key->get_precomputed());
69 }
70
71 OuterBuilder outer_builder;
72 StdlibVerificationKey vk(&outer_builder, native_vk);
73
74 // First method of hashing: using to_field_elements and add_to_hash_buffer.
75 std::vector<FF> vk_field_elements = vk.to_field_elements();
76 StdlibTranscript transcript;
77 for (const auto& field_element : vk_field_elements) {
78 transcript.add_to_independent_hash_buffer("vk_element", field_element);
79 }
80 FF vk_hash_1 = transcript.hash_independent_buffer();
81 // Second method of hashing: using hash().
82 FF vk_hash_2 = vk.hash(outer_builder);
83 EXPECT_EQ(vk_hash_1.get_value(), vk_hash_2.get_value());
84 // Third method of hashing: using hash_through_transcript.
85 if constexpr (!IsAnyOf<Flavor, TranslatorRecursiveFlavor, ECCVMRecursiveFlavor>) {
86 StdlibTranscript transcript_2;
87 FF vk_hash_3 = vk.hash_through_transcript("", transcript_2);
88 EXPECT_EQ(vk_hash_2.get_value(), vk_hash_3.get_value());
89 }
90}
typename Flavor::NativeFlavor NativeFlavor
void set_default_pairing_points_and_ipa_claim_and_proof(typename NativeFlavor::CircuitBuilder &builder)
A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the informat...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:95
NativeTranscript Transcript
MegaCircuitBuilder CircuitBuilder
The recursive counterpart to the "native" Mega flavor.
The recursive counterpart of the native Translator flavor.
The recursive counterpart to the "native" Ultra flavor.
The recursive counterpart to the "native" UltraRollupFlavor.
AluTraceBuilder builder
Definition alu.test.cpp:123
testing::Types< MegaFlavor, UltraFlavor, UltraZKFlavor, UltraRollupFlavor > FlavorTypes
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
typename Flavor::FF FF
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.