Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
flavor_serialization.test.cpp
Go to the documentation of this file.
16
17#include <gtest/gtest.h>
18
19using namespace bb;
20
21template <typename Flavor> class FlavorSerializationTests : public ::testing::Test {
22 public:
26
27 protected:
29};
30
31#ifdef STARKNET_GARAGA_FLAVORS
32using FlavorTypes = testing::Types<UltraFlavor, UltraKeccakFlavor, UltraStarknetFlavor, MegaFlavor>;
33#else
34using FlavorTypes = testing::Types<UltraFlavor, UltraKeccakFlavor, MegaFlavor>;
35#endif
37
38// Test msgpack serialization/deserialization of verification keys
39TYPED_TEST(FlavorSerializationTests, VerificationKeySerialization)
40{
41 using Builder = typename TestFixture::Builder;
42 using ProverInstance = typename TestFixture::ProverInstance;
43 using VerificationKey = typename TestFixture::VerificationKey;
44
46
47 // Add some arbitrary arithmetic gates that utilize public inputs
49
51 auto prover_instance = std::make_shared<ProverInstance>(builder);
52 VerificationKey original_vkey{ prover_instance->get_precomputed() };
53
54 // Serialize and deserialize the verification key
55 std::vector<uint8_t> vkey_buffer = to_buffer(original_vkey);
56 VerificationKey deserialized_vkey = from_buffer<VerificationKey>(vkey_buffer);
57
58 // Ensure the original is equal to the reconstructed
59 EXPECT_EQ(original_vkey, deserialized_vkey);
60}
typename Flavor::CircuitBuilder Builder
typename Flavor::VerificationKey VerificationKey
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
ECCVMCircuitBuilder CircuitBuilder
static void add_arithmetic_gates_with_public_inputs(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates (with public inputs) to the provided circuit.
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
static void add_default(Builder &builder)
Add default public inputs when they are not present.
AluTraceBuilder builder
Definition alu.test.cpp:124
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.
Definition api.hpp:5
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::vector< uint8_t > to_buffer(T const &value)