Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
native_verification_key.test.cpp
Go to the documentation of this file.
10
11#include <gtest/gtest.h>
12
13using namespace bb;
14
15#ifdef STARKNET_GARAGA_FLAVORS
16using FlavorTypes = testing::Types<UltraFlavor,
19 UltraStarknetFlavor,
23#else
25 testing::Types<UltraFlavor, UltraKeccakFlavor, UltraRollupFlavor, MegaFlavor, ECCVMFlavor, TranslatorFlavor>;
26#endif
27
28template <typename Flavor> class NativeVerificationKeyTests : public ::testing::Test {
29 public:
32
34 {
36 if constexpr (HasIPAAccumulator<Flavor>) {
37 auto [stdlib_opening_claim, ipa_proof] =
38 IPA<stdlib::grumpkin<typename Flavor::CircuitBuilder>>::create_fake_ipa_claim_and_proof(builder);
39 stdlib_opening_claim.set_public();
40 builder.ipa_proof = ipa_proof;
41 }
42 }
43
45 {
46 if constexpr (IsUltraOrMegaHonk<Flavor>) {
51 return VerificationKey{ proving_key->get_precomputed() };
52 } else {
53 return VerificationKey();
54 }
55 }
56
57 protected:
59};
61
68{
69 using Flavor = TypeParam;
71 using Transcript = typename Flavor::Transcript;
72 using DataType = typename Transcript::DataType;
73
74 VerificationKey vk(TestFixture::create_vk());
75
76 // First method of hashing: using to_field_elements and add_to_hash_buffer.
77 std::vector<DataType> vk_field_elements = vk.to_field_elements();
78 Transcript transcript;
79 for (const auto& field_element : vk_field_elements) {
80 transcript.add_to_independent_hash_buffer("vk_element", field_element);
81 }
82 fr vk_hash_1 = transcript.hash_independent_buffer();
83 // Second method of hashing: using hash().
84 fr vk_hash_2 = vk.hash();
85 EXPECT_EQ(vk_hash_1, vk_hash_2);
86 if constexpr (!IsAnyOf<Flavor, ECCVMFlavor, TranslatorFlavor>) {
87 // Third method of hashing: using hash_through_transcript.
88 typename Flavor::Transcript transcript_2;
89 fr vk_hash_3 = vk.hash_through_transcript("", transcript_2);
90 EXPECT_EQ(vk_hash_2, vk_hash_3);
91 }
92}
93
103{
104 using Flavor = TypeParam;
106
107 VerificationKey vk(TestFixture::create_vk());
108 EXPECT_EQ(vk.to_field_elements().size(), VerificationKey::VERIFICATION_KEY_LENGTH);
109}
typename Flavor::CircuitBuilder Builder
void set_default_pairing_points_and_ipa_claim_and_proof(typename Flavor::CircuitBuilder &builder)
typename Flavor::VerificationKey VerificationKey
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
DataType hash_independent_buffer()
Hashes the independent hash buffer and clears it.
void add_to_independent_hash_buffer(const std::string &label, const T &element)
Adds an element to an independent hash buffer.
TranscriptParams::DataType DataType
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
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
NativeTranscript Transcript
MegaCircuitBuilder CircuitBuilder
AluTraceBuilder builder
Definition alu.test.cpp:123
UltraKeccakFlavor::VerificationKey VerificationKey
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)
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.