Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
protogalaxy.test.cpp
Go to the documentation of this file.
12
13#include <gtest/gtest.h>
14
15using namespace bb;
16
17namespace {
18
20
21template <typename Flavor> class ProtogalaxyTests : public testing::Test {
22 public:
23 using FF = typename Flavor::FF;
24 using Affine = typename Flavor::Commitment;
25 using Projective = typename Flavor::GroupElement;
26 using Polynomial = typename Flavor::Polynomial;
29 using WitnessCommitments = typename Flavor::WitnessCommitments;
30 using CommitmentKey = typename Flavor::CommitmentKey;
32 using ProtogalaxyTestUtils = ProtogalaxyTestUtilities<Flavor>;
34 using VerifierInstance = ProtogalaxyTestUtils::VerifierInstance;
35 using ProverInstances = ProtogalaxyTestUtils::ProverInstances;
37 using VerifierInstances = ProtogalaxyTestUtils::VerifierInstances;
38 using TupleOfKeys = ProtogalaxyTestUtils::TupleOfKeys;
40 using FoldingProver = ProtogalaxyTestUtils::FoldingProver;
41 using FoldingVerifier = ProtogalaxyTestUtils::FoldingVerifier;
42 using DeciderProver = ProtogalaxyTestUtils::DeciderProver;
43 using DeciderVerifier = ProtogalaxyTestUtils::DeciderVerifier;
45
46 static void SetUpTestSuite() { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); }
47
54 static void test_full_honk_evaluations_valid_circuit()
55 {
58
59 auto prover_inst = std::make_shared<ProverInstance>(builder);
60
62
63 for (auto& alpha : prover_inst->alphas) {
64 alpha = FF::random_element();
65 }
66 PGInternal pg_internal;
67 auto full_honk_evals = pg_internal.compute_row_evaluations(
68 prover_inst->polynomials, prover_inst->alphas, prover_inst->relation_parameters);
69
70 // Evaluations should be 0 for valid circuit
71 for (const auto& eval : full_honk_evals.coeffs()) {
72 EXPECT_EQ(eval, FF(0));
73 }
74 }
75
81 static void test_pertubator_coefficients()
82 {
83 std::vector<FF> betas = { FF(5), FF(8), FF(11) };
84 std::vector<FF> deltas = { FF(2), FF(4), FF(8) };
85 std::vector<FF> full_honk_evaluations = { FF(1), FF(1), FF(1), FF(1), FF(1), FF(1), FF(1), FF(1) };
86 Polynomial honk_evaluations_poly(full_honk_evaluations.size());
87 for (auto [poly_val, val] : zip_view(honk_evaluations_poly.coeffs(), full_honk_evaluations)) {
88 poly_val = val;
89 }
90 auto perturbator = PGInternal::construct_perturbator_coefficients(betas, deltas, honk_evaluations_poly);
91 std::vector<FF> expected_values = { FF(648), FF(936), FF(432), FF(64) };
92 EXPECT_EQ(perturbator.size(), 4); // log(size) + 1
93 for (size_t i = 0; i < perturbator.size(); i++) {
94 EXPECT_EQ(perturbator[i], expected_values[i]);
95 }
96 }
97
103 static void test_pertubator_polynomial()
104 {
105 using SubrelationSeparators = typename Flavor::SubrelationSeparators;
106 const size_t log_size(3);
107 const size_t size(1 << log_size);
108 // Construct fully random prover polynomials
109 ProverPolynomials full_polynomials;
110 for (auto& poly : full_polynomials.get_all()) {
111 poly = bb::Polynomial<FF>::random(size);
112 }
113
114 auto relation_parameters = bb::RelationParameters<FF>::get_random();
115 SubrelationSeparators alphas;
116 for (auto& alpha : alphas) {
117 alpha = FF::random_element();
118 }
119
120 PGInternal pg_internal;
121 auto full_honk_evals = pg_internal.compute_row_evaluations(full_polynomials, alphas, relation_parameters);
122 std::vector<FF> betas(log_size);
123 for (size_t idx = 0; idx < log_size; idx++) {
124 betas[idx] = FF::random_element();
125 }
126
127 // Construct pow(\vec{betas}) as in the paper
128 bb::GateSeparatorPolynomial gate_separators(betas, log_size);
129
130 // Compute the corresponding target sum and create a dummy accumulator
131 auto target_sum = FF(0);
132 for (size_t i = 0; i < size; i++) {
133 target_sum += full_honk_evals[i] * gate_separators[i];
134 }
135
136 auto accumulator = std::make_shared<ProverInstance>();
137 accumulator->polynomials = std::move(full_polynomials);
138 accumulator->set_dyadic_size(1 << log_size);
139 accumulator->gate_challenges = betas;
140 accumulator->target_sum = target_sum;
141 accumulator->relation_parameters = relation_parameters;
142 accumulator->alphas = alphas;
143
144 std::vector<FF> deltas(log_size);
145 for (size_t idx = 0; idx < log_size; idx++) {
146 deltas[idx] = FF::random_element();
147 }
148 auto perturbator = pg_internal.compute_perturbator(accumulator, deltas);
149
150 // Ensure the constant coefficient of the perturbator is equal to the target sum as indicated by the paper
151 EXPECT_EQ(perturbator[0], target_sum);
152 }
153
159 static void test_combiner_quotient()
160 {
161 auto perturbator_evaluation = FF(2); // F(\alpha) in the paper
162 auto combiner = bb::Univariate<FF, 12>(std::array<FF, 12>{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 });
163 auto combiner_quotient = PGInternal::compute_combiner_quotient(perturbator_evaluation, combiner);
164
165 // K(i) = (G(i) - ( L_0(i) * F(\alpha)) / Z(i), i = {2,.., 13} for ProverInstances::NUM = 2
166 // K(i) = (G(i) - (1 - i) * F(\alpha)) / i * (i - 1)
167 auto expected_evals = bb::Univariate<FF, 12, 2>(std::array<FF, 10>{
168 (FF(22) - (FF(1) - FF(2)) * perturbator_evaluation) / (FF(2) * FF(2 - 1)),
169 (FF(23) - (FF(1) - FF(3)) * perturbator_evaluation) / (FF(3) * FF(3 - 1)),
170 (FF(24) - (FF(1) - FF(4)) * perturbator_evaluation) / (FF(4) * FF(4 - 1)),
171 (FF(25) - (FF(1) - FF(5)) * perturbator_evaluation) / (FF(5) * FF(5 - 1)),
172 (FF(26) - (FF(1) - FF(6)) * perturbator_evaluation) / (FF(6) * FF(6 - 1)),
173 (FF(27) - (FF(1) - FF(7)) * perturbator_evaluation) / (FF(7) * FF(7 - 1)),
174 (FF(28) - (FF(1) - FF(8)) * perturbator_evaluation) / (FF(8) * FF(8 - 1)),
175 (FF(29) - (FF(1) - FF(9)) * perturbator_evaluation) / (FF(9) * FF(9 - 1)),
176 (FF(30) - (FF(1) - FF(10)) * perturbator_evaluation) / (FF(10) * FF(10 - 1)),
177 (FF(31) - (FF(1) - FF(11)) * perturbator_evaluation) / (FF(11) * FF(11 - 1)),
178 });
179
180 for (size_t idx = 2; idx < 7; idx++) {
181 EXPECT_EQ(combiner_quotient.value_at(idx), expected_evals.value_at(idx));
182 }
183 }
184
190 static void test_compute_extended_relation_parameters()
191 {
192 Builder builder1;
194 auto pk_1 = std::make_shared<ProverInstance>(builder1);
195 pk_1->relation_parameters.eta = 1;
196
197 Builder builder2;
198 builder2.add_variable(3);
200 auto pk_2 = std::make_shared<ProverInstance>(builder2);
201 pk_2->relation_parameters.eta = 3;
202
203 ProverInstances pks{ { pk_1, pk_2 } };
204 auto relation_parameters_no_optimistic_skipping = PGInternal::template compute_extended_relation_parameters<
206 auto relation_parameters = PGInternal::template compute_extended_relation_parameters<
208
209 bb::Univariate<FF, 11> expected_eta{ { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 } };
210 EXPECT_EQ(relation_parameters_no_optimistic_skipping.eta, expected_eta);
211 // Optimized relation parameters are the same, we just don't compute any values for non-used indices when
212 // deriving values from them
213 for (size_t i = 0; i < 11; i++) {
214 EXPECT_EQ(relation_parameters.eta.evaluations[i], expected_eta.evaluations[i]);
215 }
216 }
217
222 static void test_compute_and_extend_alphas()
223 {
224 Builder builder1;
226 auto pk_1 = std::make_shared<ProverInstance>(builder1);
227 pk_1->alphas.fill(2);
228
229 Builder builder2;
230 builder2.add_variable(3);
232 auto pk_2 = std::make_shared<ProverInstance>(builder2);
233 pk_2->alphas.fill(4);
234
235 ProverInstances pks{ { pk_1, pk_2 } };
236 auto alphas = PGInternal::compute_and_extend_alphas(pks);
237
238 bb::Univariate<FF, 12> expected_alphas{ { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 } };
239 for (const auto& alpha : alphas) {
240 EXPECT_EQ(alpha, expected_alphas);
241 }
242 }
243
249 static void test_protogalaxy_inhomogeneous()
250 {
251 auto check_fold_and_decide = [](Builder& circuit_1, Builder& circuit_2) {
252 // Construct decider key pairs for each
253 TupleOfKeys keys;
256
257 // Perform prover and verifier folding
258 auto [prover_accumulator, verifier_accumulator] =
259 ProtogalaxyTestUtils::fold_and_verify(get<0>(keys), get<1>(keys));
260 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
261
262 // Run decider
263 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator, verifier_accumulator), true);
264 };
265
266 // One circuit has more arithmetic gates
267 {
268 // Construct two equivalent circuits
269 Builder builder1;
270 Builder builder2;
273
274 // Add some arithmetic gates
275 bb::MockCircuits::add_arithmetic_gates(builder1, /*num_gates=*/4);
276
277 check_fold_and_decide(builder1, builder2);
278 }
279
280 // One circuit has more arithmetic gates with public inputs
281 {
282 // Construct two equivalent circuits
283 Builder builder1;
284 Builder builder2;
285
286 // Add some arithmetic gates with public inputs to the first circuit
288
291
292 check_fold_and_decide(builder1, builder2);
293 }
294
295 // One circuit has more lookup gates
296 {
297 // Construct two equivalent circuits
298 Builder builder1;
299 Builder builder2;
302
303 // Add a different number of lookup gates to each circuit
304 bb::MockCircuits::add_lookup_gates(builder1, /*num_iterations=*/2); // 12 gates plus 4096 table
305 bb::MockCircuits::add_lookup_gates(builder2, /*num_iterations=*/1); // 6 gates plus 4096 table
306
307 check_fold_and_decide(builder1, builder2);
308 }
309 }
310
315 static void test_protogalaxy_bad_lookup_failure()
316 {
317 // Construct two equivalent circuits
318 Builder builder1;
319 Builder builder2;
322
323 // Add a different number of lookup gates to each circuit
324 bb::MockCircuits::add_lookup_gates(builder1, /*num_iterations=*/2); // 12 gates plus 4096 table
325 bb::MockCircuits::add_lookup_gates(builder2, /*num_iterations=*/1); // 6 gates plus 4096 table
326
327 // Erroneously set a non-zero wire value to zero in one of the lookup gates
328 for (auto& wire_3_witness_idx : builder1.blocks.lookup.w_o()) {
329 if (wire_3_witness_idx != builder1.zero_idx()) {
330 wire_3_witness_idx = builder1.zero_idx();
331 break;
332 }
333 }
334
335 // Construct the key pairs for each
336 TupleOfKeys keys;
339
340 // Perform prover and verifier folding
341 auto [prover_accumulator, verifier_accumulator] =
342 ProtogalaxyTestUtils::fold_and_verify(get<0>(keys), get<1>(keys));
343
344 // Expect failure in manual target sum check and decider
345 EXPECT_FALSE(check_accumulator_target_sum_manual(prover_accumulator));
346 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator, verifier_accumulator), false);
347 }
348
353 static void test_full_protogalaxy()
354 {
355 TupleOfKeys insts = ProtogalaxyTestUtils::construct_instances(2);
356 auto [prover_accumulator, verifier_accumulator] =
357 ProtogalaxyTestUtils::fold_and_verify(get<0>(insts), get<1>(insts));
358 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
359
360 TupleOfKeys insts_2 = ProtogalaxyTestUtils::construct_instances(1); // just one key pair
361 auto [prover_accumulator_2, verifier_accumulator_2] =
362 ProtogalaxyTestUtils::fold_and_verify(ProverInstances{ prover_accumulator, get<0>(insts_2)[0] },
363 VerifierInstances{ verifier_accumulator, get<1>(insts_2)[0] });
364 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator_2));
365
366 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator_2, verifier_accumulator_2), true);
367 }
368
373 static void test_full_protogalaxy_structured_trace()
374 {
375 TraceSettings trace_settings{ SMALL_TEST_STRUCTURE_FOR_OVERFLOWS };
376 TupleOfKeys keys_1 = ProtogalaxyTestUtils::construct_instances(2, trace_settings);
377
378 auto [prover_accumulator, verifier_accumulator] =
379 ProtogalaxyTestUtils::fold_and_verify(get<0>(keys_1), get<1>(keys_1));
380 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
381
382 TupleOfKeys keys_2 = ProtogalaxyTestUtils::construct_instances(1, trace_settings); // just one key pair
383
384 auto [prover_accumulator_2, verifier_accumulator_2] =
385 ProtogalaxyTestUtils::fold_and_verify(ProverInstances{ prover_accumulator, get<0>(keys_2)[0] },
386 VerifierInstances{ verifier_accumulator, get<1>(keys_2)[0] });
387 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator_2));
388 info(prover_accumulator_2->dyadic_size());
389 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator_2, verifier_accumulator_2), true);
390 }
391
399 static void test_fold_with_virtual_size_expansion()
400 {
401 uint32_t overflow_capacity = 0; // consider the case where the overflow is not known until runtime
402 TraceSettings trace_settings{ SMALL_TEST_STRUCTURE_FOR_OVERFLOWS, overflow_capacity };
403 ExecutionTraceUsageTracker trace_usage_tracker = ExecutionTraceUsageTracker(trace_settings);
404
405 ProverInstances prover_insts;
406 VerifierInstances verifier_insts;
407
408 // define parameters for two circuits; the first fits within the structured trace, the second overflows
409 const std::vector<size_t> log2_num_gates = { 14, 18 };
410 for (size_t i = 0; i < 2; ++i) {
412
413 MockCircuits::add_arithmetic_gates(builder, 1 << log2_num_gates[i]);
415
416 auto prover_instance = std::make_shared<ProverInstance>(builder, trace_settings);
417 trace_usage_tracker.update(builder);
418 auto verification_key = std::make_shared<VerificationKey>(prover_instance->get_precomputed());
419 auto verifier_instance = std::make_shared<VerifierInstance>(verification_key);
420 prover_insts[i] = prover_instance;
421 verifier_insts[i] = verifier_instance;
422 }
423
424 // Ensure the dyadic size of the first key is strictly less than that of the second
425 EXPECT_TRUE(prover_insts[0]->dyadic_size() < prover_insts[1]->dyadic_size());
426
427 // The size discrepency should be automatically handled by the PG prover via a virtual size increase
428 const auto [prover_accumulator, verifier_accumulator] =
429 ProtogalaxyTestUtils::fold_and_verify(prover_insts, verifier_insts, trace_usage_tracker);
430 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
431 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator, verifier_accumulator), true);
432 }
433
440 static void test_full_protogalaxy_structured_trace_inhomogeneous_circuits()
441 {
442 TraceSettings trace_settings{ SMALL_TEST_STRUCTURE };
443
444 // Construct three circuits to be folded, each with a different number of constraints
445 Builder builder1;
446 Builder builder2;
447 Builder builder3;
451
452 // Construct the decider key pairs for the first two circuits
453 TupleOfKeys keys_1;
454 ProtogalaxyTestUtils::construct_instances_and_add_to_tuple(keys_1, builder1, 0, trace_settings);
455 ProtogalaxyTestUtils::construct_instances_and_add_to_tuple(keys_1, builder2, 1, trace_settings);
456
457 // Fold the first two pairs
458 auto [prover_accumulator, verifier_accumulator] =
459 ProtogalaxyTestUtils::fold_and_verify(get<0>(keys_1), get<1>(keys_1));
460 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
461
462 // Construct the decider key pair for the third circuit
463 TupleOfKeys keys_2;
464 ProtogalaxyTestUtils::construct_instances_and_add_to_tuple(keys_2, builder3, 0, trace_settings);
465
466 // Fold 3rd pair of keys into their respective accumulators
467 auto [prover_accumulator_2, verifier_accumulator_2] =
468 ProtogalaxyTestUtils::fold_and_verify(ProverInstances{ prover_accumulator, get<0>(keys_2)[0] },
469 VerifierInstances{ verifier_accumulator, get<1>(keys_2)[0] });
470 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator_2));
471 info(prover_accumulator_2->dyadic_size());
472
473 // Decide on final accumulator
474 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator_2, verifier_accumulator_2), true);
475 }
476
481 static void test_tampered_commitment()
482 {
483 TupleOfKeys insts = ProtogalaxyTestUtils::construct_instances(2);
484 auto [prover_accumulator, verifier_accumulator] =
485 ProtogalaxyTestUtils::fold_and_verify(get<0>(insts), get<1>(insts));
486 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
487
488 // Tamper with a commitment
489 verifier_accumulator->witness_commitments.w_l = Projective(Affine::random_element());
490
491 TupleOfKeys insts_2 = ProtogalaxyTestUtils::construct_instances(1); // just one decider key pair
492 auto [prover_accumulator_2, verifier_accumulator_2] =
493 ProtogalaxyTestUtils::fold_and_verify(ProverInstances{ prover_accumulator, get<0>(insts_2)[0] },
494 VerifierInstances{ verifier_accumulator, get<1>(insts_2)[0] });
495 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator_2));
496
497 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator_2, verifier_accumulator_2), false);
498 }
499
505 static void test_tampered_accumulator_polynomial()
506 {
507 TupleOfKeys insts = ProtogalaxyTestUtils::construct_instances(2);
508 auto [prover_accumulator, verifier_accumulator] =
509 ProtogalaxyTestUtils::fold_and_verify(get<0>(insts), get<1>(insts));
510 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
511
512 // Tamper with an accumulator polynomial
513 prover_accumulator->polynomials.w_l.at(1) = FF::random_element();
514 EXPECT_FALSE(check_accumulator_target_sum_manual(prover_accumulator));
515
516 TupleOfKeys insts_2 = ProtogalaxyTestUtils::construct_instances(1); // just one decider key pair
517 auto [prover_accumulator_2, verifier_accumulator_2] =
518 ProtogalaxyTestUtils::fold_and_verify(ProverInstances{ prover_accumulator, get<0>(insts_2)[0] },
519 VerifierInstances{ verifier_accumulator, get<1>(insts_2)[0] });
520
521 EXPECT_EQ(prover_accumulator_2->target_sum == verifier_accumulator_2->target_sum, false);
522 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator_2, verifier_accumulator_2), false);
523 }
524
525 template <size_t k> static void test_fold_k_key_pairs()
526 {
527 constexpr size_t total_insts = k + 1;
528 TupleOfKeys insts = ProtogalaxyTestUtils::construct_instances(total_insts);
529
530 ProtogalaxyProver_<Flavor> folding_prover(get<0>(insts), get<1>(insts), std::make_shared<NativeTranscript>());
532
533 auto [prover_accumulator, folding_proof] = folding_prover.prove();
534 auto verifier_accumulator = folding_verifier.verify_folding_proof(folding_proof);
535 EXPECT_TRUE(check_accumulator_target_sum_manual(prover_accumulator));
536 EXPECT_EQ(ProtogalaxyTestUtils::run_decider(prover_accumulator, verifier_accumulator), true);
537 }
538};
539} // namespace
540
541using FlavorTypes = testing::Types<MegaFlavor>;
542TYPED_TEST_SUITE(ProtogalaxyTests, FlavorTypes);
543
544TYPED_TEST(ProtogalaxyTests, PerturbatorCoefficients)
545{
546 TestFixture::test_pertubator_coefficients();
547}
548
549TYPED_TEST(ProtogalaxyTests, FullHonkEvaluationsValidCircuit)
550{
551 TestFixture::test_full_honk_evaluations_valid_circuit();
552}
553
554TYPED_TEST(ProtogalaxyTests, PerturbatorPolynomial)
555{
556 TestFixture::test_pertubator_polynomial();
557}
558
559TYPED_TEST(ProtogalaxyTests, CombinerQuotient)
560{
561 TestFixture::test_combiner_quotient();
562}
563
564TYPED_TEST(ProtogalaxyTests, CombineRelationParameters)
565{
566 TestFixture::test_compute_extended_relation_parameters();
567}
568
569TYPED_TEST(ProtogalaxyTests, CombineAlphas)
570{
571 TestFixture::test_compute_and_extend_alphas();
572}
573
574TYPED_TEST(ProtogalaxyTests, ProtogalaxyInhomogeneous)
575{
576 TestFixture::test_protogalaxy_inhomogeneous();
577}
578
579TYPED_TEST(ProtogalaxyTests, FullProtogalaxyTest)
580{
581 TestFixture::test_full_protogalaxy();
582}
583
584TYPED_TEST(ProtogalaxyTests, FullProtogalaxyStructuredTrace)
585{
586 TestFixture::test_full_protogalaxy_structured_trace();
587}
588
589TYPED_TEST(ProtogalaxyTests, VirtualSizeExpansion)
590{
591 TestFixture::test_fold_with_virtual_size_expansion();
592}
593
594TYPED_TEST(ProtogalaxyTests, FullProtogalaxyStructuredTraceInhomogeneous)
595{
596 TestFixture::test_full_protogalaxy_structured_trace_inhomogeneous_circuits();
597}
598
599TYPED_TEST(ProtogalaxyTests, TamperedCommitment)
600{
601 TestFixture::test_tampered_commitment();
602}
603
604TYPED_TEST(ProtogalaxyTests, TamperedAccumulatorPolynomial)
605{
606 BB_DISABLE_ASSERTS(); // Disable assert in PG prover
607 TestFixture::test_tampered_accumulator_polynomial();
608}
609
610TYPED_TEST(ProtogalaxyTests, BadLookupFailure)
611{
612 TestFixture::test_protogalaxy_bad_lookup_failure();
613}
614
615// We only fold one incoming decider key pair since this is all we plan to use, and compiling for higher values of k is
616// a significant compilation time cost.
617TYPED_TEST(ProtogalaxyTests, Fold1)
618{
619 TestFixture::template test_fold_k_key_pairs<1>();
620}
#define BB_DISABLE_ASSERTS()
Definition assert.hpp:32
CommitmentKey object over a pairing group 𝔾₁.
A container for the prover polynomials.
WitnessEntities< Commitment > WitnessCommitments
A container for the witness commitments.
Curve::ScalarField FF
bb::CommitmentKey< Curve > CommitmentKey
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
Curve::Element GroupElement
bb::Polynomial< FF > Polynomial
Curve::AffineElement Commitment
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.
static void add_lookup_gates(Builder &builder, size_t num_iterations=1)
Add lookup gates using the uint32 XOR lookup table (table size 4096)
static void add_arithmetic_gates(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates to the provided circuit.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
bb::RelationParameters< Univariate< FF, EXTENDED_LENGTH, 0, SKIP_COUNT > > UnivariateRelationParameters
A purely static class (never add state to this!) consisting of functions used by the Protogalaxy prov...
static UnivariateSubrelationSeparators compute_and_extend_alphas(const ProverInstances &instances)
Combine the relation batching parameters (alphas) from each prover instance into a univariate for the...
static std::vector< FF > construct_perturbator_coefficients(std::span< const FF > betas, std::span< const FF > deltas, const Polynomial< FF > &full_honk_evaluations)
Construct the perturbator polynomial F(X) coefficients in O(n) time using binary tree reduction.
static Univariate< FF, BATCHED_EXTENDED_LENGTH, NUM_INSTANCES > compute_combiner_quotient(FF perturbator_evaluation, ExtendedUnivariateWithRandomization combiner)
Compute the combiner quotient defined as $K$ polynomial in the paper specialised for only folding two...
bb::RelationParameters< Univariate< FF, EXTENDED_LENGTH > > UnivariateRelationParametersNoOptimisticSkipping
std::array< std::shared_ptr< VerifierInstance >, NUM_INSTANCES > VerifierInstances
typename Flavor::VerificationKey VerificationKey
static void create_function_circuit(Builder &builder, const size_t &log_num_gates=9, const size_t &log_num_gates_with_public_inputs=9)
Create a circuit with the specified number of arithmetic gates and arithmetic gates with public input...
DeciderProver_< Flavor > DeciderProver
ProtogalaxyVerifier_< VerifierInstance > FoldingVerifier
static FoldingData fold_and_verify(const ProverInstances &prover_instances, const VerifierInstances &verification_keys, ExecutionTraceUsageTracker trace_usage_tracker=ExecutionTraceUsageTracker{}, bool hash_accumulator=false)
Fold two prover instances and generate folded verifier by running the PG verifier.
ProtogalaxyProver_< Flavor > FoldingProver
std::array< std::shared_ptr< ProverInstance >, NUM_INSTANCES > ProverInstances
DeciderVerifier_< Flavor > DeciderVerifier
std::tuple< ProverInstances, VerifierInstances > TupleOfKeys
static bool run_decider(const std::shared_ptr< ProverInstance > &prover_accumulator, const std::shared_ptr< VerifierInstance > &verifier_accumulator)
Run the decider on the given accumulator.
static void construct_instances_and_add_to_tuple(TupleOfKeys &keys, Builder &builder, size_t idx=0, TraceSettings trace_settings=TraceSettings{})
Construct Prover and Verifier instances for a provided circuit and add to tuple.
VerifierInstance_< Flavor > VerifierInstance
static TupleOfKeys construct_instances(size_t num_keys, TraceSettings trace_settings=TraceSettings{}, bool circuits_of_different_size=false)
Construct a given number of Prover and Verifier instances.
ProverInstance_< Flavor > ProverInstance
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
Fr & value_at(size_t i)
static void complete_prover_instance_for_test(const std::shared_ptr< ProverInstance_< Flavor > > &prover_inst)
TEST only method for completing computation of the prover polynomials using random challenges.
void info(Args... args)
Definition log.hpp:74
AluTraceBuilder builder
Definition alu.test.cpp:123
typename ECCVMFlavor::ProverPolynomials ProverPolynomials
UltraKeccakFlavor::VerificationKey VerificationKey
testing::Types< MegaFlavor, UltraFlavor, UltraZKFlavor, UltraRollupFlavor > FlavorTypes
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:190
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)
typename Flavor::FF FF
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Tracks the cumulative usage of the execution trace across a series of circuits.
Implementation of the methods for the -polynomials used in in Sumcheck.
Container for parameters used by the grand product (permutation, lookup) Honk relations.
static RelationParameters get_random()
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.