1
+
2
+ #include < benchmark/benchmark.h>
3
+
4
+ #include " barretenberg/benchmark/honk_bench/benchmark_utilities.hpp"
5
+ #include " barretenberg/goblin/goblin.hpp"
6
+ #include " barretenberg/goblin/mock_circuits.hpp"
7
+ #include " barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
8
+ #include " barretenberg/ultra_honk/ultra_composer.hpp"
9
+
10
+ using namespace benchmark ;
11
+ using namespace barretenberg ;
12
+ using namespace proof_system ;
13
+
14
+ namespace {
15
+ void goblin_full (State& state) noexcept
16
+ {
17
+ barretenberg::srs::init_crs_factory (" ../srs_db/ignition" );
18
+ barretenberg::srs::init_grumpkin_crs_factory (" ../srs_db/grumpkin" );
19
+
20
+ Goblin goblin;
21
+
22
+ // Construct an initial circuit; its proof will be recursively verified by the first kernel
23
+ GoblinUltraCircuitBuilder initial_circuit{ goblin.op_queue };
24
+ GoblinMockCircuits::construct_simple_initial_circuit (initial_circuit);
25
+ Goblin::AccumulationOutput kernel_input = goblin.accumulate (initial_circuit);
26
+
27
+ Goblin::Proof proof;
28
+ for (auto _ : state) {
29
+ // Construct a series of simple Goblin circuits; generate and verify their proofs
30
+ size_t NUM_CIRCUITS = 1 << static_cast <size_t >(state.range (0 ));
31
+ for (size_t circuit_idx = 0 ; circuit_idx < NUM_CIRCUITS; ++circuit_idx) {
32
+ // Construct a circuit with logic resembling that of the "kernel circuit"
33
+ GoblinUltraCircuitBuilder circuit_builder{ goblin.op_queue };
34
+ GoblinMockCircuits::construct_mock_kernel_circuit (circuit_builder, kernel_input);
35
+
36
+ // Construct proof of the current kernel circuit to be recursively verified by the next one
37
+ kernel_input = goblin.accumulate (circuit_builder);
38
+ }
39
+
40
+ proof = goblin.prove ();
41
+ // Verify the final ultra proof
42
+ }
43
+ honk::GoblinUltraVerifier ultra_verifier{ kernel_input.verification_key };
44
+ ultra_verifier.verify_proof (kernel_input.proof );
45
+ // Verify the goblin proof (eccvm, translator, merge)
46
+ goblin.verify (proof);
47
+ }
48
+
49
+ void goblin_accumulate (State& state) noexcept
50
+ {
51
+ barretenberg::srs::init_crs_factory (" ../srs_db/ignition" );
52
+ barretenberg::srs::init_grumpkin_crs_factory (" ../srs_db/grumpkin" );
53
+
54
+ Goblin goblin;
55
+
56
+ // Construct an initial circuit; its proof will be recursively verified by the first kernel
57
+ GoblinUltraCircuitBuilder initial_circuit{ goblin.op_queue };
58
+ GoblinMockCircuits::construct_simple_initial_circuit (initial_circuit);
59
+ Goblin::AccumulationOutput kernel_input = goblin.accumulate (initial_circuit);
60
+
61
+ // Construct a series of simple Goblin circuits; generate and verify their proofs
62
+ size_t NUM_CIRCUITS = 1 << static_cast <size_t >(state.range (0 ));
63
+ for (auto _ : state) {
64
+ for (size_t circuit_idx = 0 ; circuit_idx < NUM_CIRCUITS; ++circuit_idx) {
65
+ // Construct a circuit with logic resembling that of the "kernel circuit"
66
+ GoblinUltraCircuitBuilder circuit_builder{ goblin.op_queue };
67
+ GoblinMockCircuits::construct_mock_kernel_circuit (circuit_builder, kernel_input);
68
+
69
+ // Construct proof of the current kernel circuit to be recursively verified by the next one
70
+ kernel_input = goblin.accumulate (circuit_builder);
71
+ }
72
+ }
73
+ }
74
+
75
+ void goblin_eccvm_prove (State& state) noexcept
76
+ {
77
+ barretenberg::srs::init_crs_factory (" ../srs_db/ignition" );
78
+ barretenberg::srs::init_grumpkin_crs_factory (" ../srs_db/grumpkin" );
79
+
80
+ Goblin goblin;
81
+
82
+ // Construct an initial circuit; its proof will be recursively verified by the first kernel
83
+ GoblinUltraCircuitBuilder initial_circuit{ goblin.op_queue };
84
+ GoblinMockCircuits::construct_simple_initial_circuit (initial_circuit);
85
+ Goblin::AccumulationOutput kernel_input = goblin.accumulate (initial_circuit);
86
+
87
+ // Construct a series of simple Goblin circuits; generate and verify their proofs
88
+ size_t NUM_CIRCUITS = 1 << static_cast <size_t >(state.range (0 ));
89
+ for (size_t circuit_idx = 0 ; circuit_idx < NUM_CIRCUITS; ++circuit_idx) {
90
+ // Construct a circuit with logic resembling that of the "kernel circuit"
91
+ GoblinUltraCircuitBuilder circuit_builder{ goblin.op_queue };
92
+ GoblinMockCircuits::construct_mock_kernel_circuit (circuit_builder, kernel_input);
93
+
94
+ // Construct proof of the current kernel circuit to be recursively verified by the next one
95
+ kernel_input = goblin.accumulate (circuit_builder);
96
+ }
97
+
98
+ for (auto _ : state) {
99
+ goblin.prove_eccvm ();
100
+ }
101
+ }
102
+
103
+ void goblin_translator_prove (State& state) noexcept
104
+ {
105
+ barretenberg::srs::init_crs_factory (" ../srs_db/ignition" );
106
+ barretenberg::srs::init_grumpkin_crs_factory (" ../srs_db/grumpkin" );
107
+
108
+ Goblin goblin;
109
+
110
+ // Construct an initial circuit; its proof will be recursively verified by the first kernel
111
+ GoblinUltraCircuitBuilder initial_circuit{ goblin.op_queue };
112
+ GoblinMockCircuits::construct_simple_initial_circuit (initial_circuit);
113
+ Goblin::AccumulationOutput kernel_input = goblin.accumulate (initial_circuit);
114
+
115
+ // Construct a series of simple Goblin circuits; generate and verify their proofs
116
+ size_t NUM_CIRCUITS = 1 << static_cast <size_t >(state.range (0 ));
117
+ for (size_t circuit_idx = 0 ; circuit_idx < NUM_CIRCUITS; ++circuit_idx) {
118
+ // Construct a circuit with logic resembling that of the "kernel circuit"
119
+ GoblinUltraCircuitBuilder circuit_builder{ goblin.op_queue };
120
+ GoblinMockCircuits::construct_mock_kernel_circuit (circuit_builder, kernel_input);
121
+
122
+ // Construct proof of the current kernel circuit to be recursively verified by the next one
123
+ kernel_input = goblin.accumulate (circuit_builder);
124
+ }
125
+
126
+ goblin.prove_eccvm ();
127
+ for (auto _ : state) {
128
+ goblin.prove_translator ();
129
+ }
130
+ }
131
+
132
+ } // namespace
133
+
134
+ BENCHMARK (goblin_full)->Unit(kMillisecond )->DenseRange(0 , 7 );
135
+ BENCHMARK (goblin_accumulate)->Unit(kMillisecond )->DenseRange(0 , 7 );
136
+ BENCHMARK (goblin_eccvm_prove)->Unit(kMillisecond )->DenseRange(0 , 7 );
137
+ BENCHMARK (goblin_translator_prove)->Unit(kMillisecond )->DenseRange(0 , 7 );
0 commit comments