Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy.bench.cpp
Go to the documentation of this file.
1#include <benchmark/benchmark.h>
2
10
11using namespace benchmark;
12
13namespace bb {
14
16using FF = typename Flavor::FF;
17
18void vector_of_evaluations(State& state) noexcept
19{
20 using RelationEvaluations = decltype(create_tuple_of_arrays_of_values<typename Flavor::Relations>());
21
22 for (auto _ : state) {
23 std::vector<RelationEvaluations> evals(1 << state.range(0));
24 DoNotOptimize(evals);
25 }
26}
27
28void compute_row_evaluations(State& state) noexcept
29{
31 using Polys = Flavor::ProverPolynomials;
32 using Alphas = Flavor::SubrelationSeparators;
34
35 const size_t dyadic_size = 1 << state.range(0);
36 Polys polys(dyadic_size);
37 Alphas alphas;
38 auto params = Params::get_random();
39
40 for (auto _ : state) {
41 PGInternal pg_internal;
42 auto result = pg_internal.compute_row_evaluations(polys, alphas, params);
43 DoNotOptimize(result);
44 }
45}
46
47// Fold one proving key into an accumulator.
48void fold_k(State& state) noexcept
49{
50 static constexpr size_t k{ 1 };
51
53 using DeciderVerificationKey = DeciderVerificationKey_<Flavor>;
54 using ProtogalaxyProver = ProtogalaxyProver_<Flavor, k + 1>;
55 using Builder = typename Flavor::CircuitBuilder;
56
58
59 auto log2_num_gates = static_cast<size_t>(state.range(0));
60
61 const auto construct_key = [&]() {
65 };
68 // TODO(https://github.com/AztecProtocol/barretenberg/issues/938): Parallelize this loop
69 for (size_t i = 0; i < k + 1; ++i) {
70 std::shared_ptr<DeciderProvingKey> decider_pk = construct_key();
71 auto honk_vk = std::make_shared<Flavor::VerificationKey>(decider_pk->get_precomputed());
73 decider_pks.emplace_back(decider_pk);
74 decider_vks.emplace_back(decider_vk);
75 }
78
79 ProtogalaxyProver folding_prover(decider_pks, decider_vks, transcript);
80
81 for (auto _ : state) {
83 auto proof = folding_prover.prove();
84 }
85}
86
87BENCHMARK(vector_of_evaluations)->DenseRange(15, 21)->Unit(kMillisecond)->Iterations(1);
88BENCHMARK(compute_row_evaluations)->DenseRange(15, 21)->Unit(kMillisecond);
89// We stick to just k=1 for compile-time reasons.
90BENCHMARK(fold_k)->/* vary the circuit size */ DenseRange(14, 20)->Unit(kMillisecond);
91
92} // namespace bb
93
A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the informat...
The DeciderVerificationKey encapsulates all the necessary information for a Mega Honk Verifier to ver...
A container for the prover polynomials handles.
Curve::ScalarField FF
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
MegaCircuitBuilder CircuitBuilder
static void construct_arithmetic_circuit(Builder &builder, const size_t target_log2_dyadic_size=4, bool include_public_inputs=true)
Populate a builder with a specified number of arithmetic gates; includes a PI.
A purely static class (never add state to this!) consisting of functions used by the Protogalaxy prov...
AluTraceBuilder builder
Definition alu.test.cpp:123
crypto::Poseidon2Bn254ScalarFieldParams Params
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
DenseRange(MIN_LOG_NUM_GRUMPKIN_POINTS, MAX_LOG_NUM_GRUMPKIN_POINTS) -> Unit(benchmark::kMillisecond)
typename Flavor::FF FF
void compute_row_evaluations(State &state) noexcept
void vector_of_evaluations(State &state) noexcept
BENCHMARK(vector_of_evaluations) -> DenseRange(15, 21) ->Unit(kMillisecond) ->Iterations(1)
void fold_k(State &state) noexcept
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define BB_REPORT_OP_COUNT_IN_BENCH(state)
BENCHMARK_MAIN()
Container for parameters used by the grand product (permutation, lookup) Honk relations.