Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
eccvm.bench.cpp
Go to the documentation of this file.
1#include <benchmark/benchmark.h>
2
6
7using namespace benchmark;
8using namespace bb;
9
13
14namespace {
15
16Builder generate_trace(size_t target_num_gates)
17{
19 using G1 = typename Flavor::CycleGroup;
20 using Fr = typename G1::Fr;
21
22 auto generators = get_precomputed_generators<G1, "test generators", 2>();
23
24 typename G1::element a = generators[0];
25 typename G1::element b = generators[1];
28
29 // Each loop adds 163 gates. Note: builder.get_estimated_num_finalized_gates() is very expensive here (bug?) and
30 // it's actually painful to use a `while` loop
31 size_t num_iterations = target_num_gates / 163;
32 for (size_t _ = 0; _ < num_iterations; _++) {
33 op_queue->add_accumulate(a);
34 op_queue->mul_accumulate(a, x);
35 op_queue->mul_accumulate(b, x);
36 op_queue->mul_accumulate(b, y);
37 op_queue->add_accumulate(a);
38 op_queue->mul_accumulate(b, x);
39 op_queue->eq_and_reset();
40 op_queue->merge();
41 }
42
43 Builder builder{ op_queue };
44 return builder;
45}
46
47void eccvm_generate_prover(State& state) noexcept
48{
49
50 size_t target_num_gates = 1 << static_cast<size_t>(state.range(0));
51 for (auto _ : state) {
52 Builder builder = generate_trace(target_num_gates);
53 std::shared_ptr<Transcript> prover_transcript = std::make_shared<Transcript>();
54 ECCVMProver prover(builder, prover_transcript);
55 };
56}
57
58void eccvm_prove(State& state) noexcept
59{
60
61 size_t target_num_gates = 1 << static_cast<size_t>(state.range(0));
62 Builder builder = generate_trace(target_num_gates);
63 std::shared_ptr<Transcript> prover_transcript = std::make_shared<Transcript>();
64 ECCVMProver prover(builder, prover_transcript);
65 for (auto _ : state) {
66 ECCVMProof proof = prover.construct_proof();
67 };
68}
69
70BENCHMARK(eccvm_generate_prover)->Unit(kMillisecond)->DenseRange(12, CONST_ECCVM_LOG_N);
71BENCHMARK(eccvm_prove)->Unit(kMillisecond)->DenseRange(12, CONST_ECCVM_LOG_N);
72} // namespace
73
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
NativeTranscript Transcript
ECCVMProof construct_proof()
AluTraceBuilder builder
Definition alu.test.cpp:123
FF a
FF b
BENCHMARK_MAIN()
Entry point for Barretenberg command-line interface.
BENCHMARK(vector_of_evaluations) -> DenseRange(15, 21) ->Unit(kMillisecond) ->Iterations(1)
constexpr std::span< const typename Group::affine_element > get_precomputed_generators()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Curve::AffineElement G1
static field random_element(numeric::RNG *engine=nullptr) noexcept