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_random_valid_ipa_claim_and_proof(
39 builder);
40 stdlib_opening_claim.set_public();
41 builder.ipa_proof = ipa_proof;
42 }
43 }
44
46 {
47 if constexpr (IsUltraOrMegaHonk<Flavor>) {
51 auto prover_instance = std::make_shared<ProverInstance>(builder);
52 return VerificationKey{ prover_instance->get_precomputed() };
53 } else {
54 return VerificationKey();
55 }
56 }
57
58 protected:
60};
62
69{
70 using Flavor = TypeParam;
72 using Transcript = typename Flavor::Transcript;
73 using DataType = typename Transcript::DataType;
74
75 VerificationKey vk(TestFixture::create_vk());
76
77 // First method of hashing: using to_field_elements and add_to_hash_buffer.
78 std::vector<DataType> vk_field_elements = vk.to_field_elements();
79 Transcript transcript;
80 for (const auto& field_element : vk_field_elements) {
81 transcript.add_to_independent_hash_buffer("vk_element", field_element);
82 }
83 fr vk_hash_1 = transcript.hash_independent_buffer();
84 // Second method of hashing: using hash().
85 fr vk_hash_2 = vk.hash();
86 EXPECT_EQ(vk_hash_1, vk_hash_2);
87 if constexpr (!IsAnyOf<Flavor, ECCVMFlavor, TranslatorFlavor>) {
88 // Third method of hashing: using hash_through_transcript.
89 typename Flavor::Transcript transcript_2;
90 fr vk_hash_3 = vk.hash_through_transcript("", transcript_2);
91 EXPECT_EQ(vk_hash_2, vk_hash_3);
92 }
93}
94
104{
105 using Flavor = TypeParam;
107
108 VerificationKey vk(TestFixture::create_vk());
109 EXPECT_EQ(vk.to_field_elements().size(), VerificationKey::calc_num_data_types());
110}
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...
typename Codec::DataType DataType
void add_to_independent_hash_buffer(const std::string &label, const T &element)
Adds an element to an independent hash buffer.
DataType hash_independent_buffer()
Hashes the independent hash buffer and clears it.
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:93
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
NativeTranscript Transcript
MegaCircuitBuilder CircuitBuilder
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
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.