Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
sumcheck_client_ivc.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8
25#include <algorithm>
26
27namespace bb {
28
38class SumcheckClientIVC : public IVCBase {
39
40 public:
44 using FF = Flavor::FF;
47 using Point = Flavor::Curve::AffineElement;
48 using FoldProof = std::vector<FF>;
52 using ClientCircuit = MegaCircuitBuilder; // can only be Mega
62
74
83
84 // New stuff
87
88 // Merge commitments
90
98 struct Proof {
101
108 static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n = MegaZKFlavor::VIRTUAL_LOG_N)
109 {
110 return /*mega_proof*/ MegaZKFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n) +
111 /*merge_proof*/ MERGE_PROOF_SIZE +
112 /*eccvm pre-ipa proof*/ (ECCVMFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS - IPA_PROOF_LENGTH) +
113 /*eccvm ipa proof*/ IPA_PROOF_LENGTH +
115 }
116
123 static constexpr size_t PROOF_LENGTH(size_t virtual_log_n = MegaZKFlavor::VIRTUAL_LOG_N)
124 {
125 return PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n) +
127 }
128
129 size_t size() const;
130
136 std::vector<FF> to_field_elements() const;
137
139
140 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1299): The following msgpack methods are generic
141 // and should leverage some kind of shared msgpack utility.
142 msgpack::sbuffer to_msgpack_buffer() const;
143
151 uint8_t* to_msgpack_heap_buffer() const;
152 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ClientIVCProof";
153
154 class DeserializationError : public std::runtime_error {
155 public:
156 DeserializationError(const std::string& msg)
157 : std::runtime_error(std::string("Client IVC Proof deserialization error: ") + msg)
158 {}
159 };
160
161 static Proof from_msgpack_buffer(uint8_t const*& buffer);
162 static Proof from_msgpack_buffer(const msgpack::sbuffer& buffer);
163
164 void to_file_msgpack(const std::string& filename) const;
165 static Proof from_file_msgpack(const std::string& filename);
166
168 bool operator==(const Proof& other) const = default;
169 };
170
175
185
191 {
192 std::vector<bb::fr> elements;
193
194 auto mega_elements = mega->to_field_elements();
195 elements.insert(elements.end(), mega_elements.begin(), mega_elements.end());
196
197 auto eccvm_elements = eccvm->to_field_elements();
198 elements.insert(elements.end(), eccvm_elements.begin(), eccvm_elements.end());
199
200 auto translator_elements = translator->to_field_elements();
201 elements.insert(elements.end(), translator_elements.begin(), translator_elements.end());
202
203 return elements;
204 }
205
212 {
213 size_t read_idx = 0;
214
216 size_t mega_read = mega->from_field_elements(elements.subspan(read_idx));
217 read_idx += mega_read;
218
220 size_t eccvm_read = eccvm->from_field_elements(elements.subspan(read_idx));
221 read_idx += eccvm_read;
222
224 size_t translator_read = translator->from_field_elements(elements.subspan(read_idx));
225 read_idx += translator_read;
226
227 return read_idx;
228 }
229 };
230
238
240 std::vector<FF> challenge;
242 std::array<Commitment, 2> batched_commitments;
243
244 FF hash_through_transcript(const std::string& domain_separator, Transcript& transcript) const
245 {
246 for (size_t idx = 0; idx < challenge.size(); idx++) {
247 transcript.add_to_independent_hash_buffer(domain_separator + "challenge_" + std::to_string(idx),
248 challenge[idx]);
249 }
250 transcript.add_to_independent_hash_buffer(domain_separator + "batched_evaluation_unshifted",
252 transcript.add_to_independent_hash_buffer(domain_separator + "batched_evaluation_shifted",
254 transcript.add_to_independent_hash_buffer(domain_separator + "batched_commitment_unshifted",
256 transcript.add_to_independent_hash_buffer(domain_separator + "batched_commitment_shifted",
258 return transcript.hash_independent_buffer();
259 }
260 };
261
263 std::vector<StdlibFF> challenge;
264 std::array<StdlibFF, 2> batched_evaluations;
265 std::array<RecursiveCommitment, 2> batched_commitments;
266
268 RecursiveVerifierAccumulator(const std::vector<StdlibFF>& challenge,
269 const std::array<StdlibFF, 2>& batched_evaluations,
270 const std::array<RecursiveCommitment, 2>& batched_commitments)
274 {}
276 {
277 for (auto element : native_accumulator.challenge) {
278 challenge.emplace_back(StdlibFF::from_witness(builder, element));
279 }
280
281 batched_evaluations[0] = StdlibFF::from_witness(builder, native_accumulator.batched_evaluations[0]);
282 batched_evaluations[1] = StdlibFF::from_witness(builder, native_accumulator.batched_evaluations[1]);
283
285 RecursiveCommitment::from_witness(builder, native_accumulator.batched_commitments[0]);
287 RecursiveCommitment::from_witness(builder, native_accumulator.batched_commitments[1]);
288 }
289
290 StdlibFF hash_through_transcript(const std::string& domain_separator, RecursiveTranscript& transcript) const
291 {
292 for (size_t idx = 0; idx < challenge.size(); idx++) {
293 transcript.add_to_independent_hash_buffer(domain_separator + "challenge_" + std::to_string(idx),
294 challenge[idx]);
295 }
296 transcript.add_to_independent_hash_buffer(domain_separator + "batched_evaluation_unshifted",
298 transcript.add_to_independent_hash_buffer(domain_separator + "batched_evaluation_shifted",
300 transcript.add_to_independent_hash_buffer(domain_separator + "batched_commitment_unshifted",
302 transcript.add_to_independent_hash_buffer(domain_separator + "batched_commitment_shifted",
304 return transcript.hash_independent_buffer();
305 }
306
308 {
310
311 for (auto element : challenge) {
312 value.challenge.emplace_back(element.get_value());
313 }
314
315 value.batched_evaluations[0] = batched_evaluations[0].get_value();
316 value.batched_evaluations[1] = batched_evaluations[1].get_value();
317
318 value.batched_commitments[0] = batched_commitments[0].get_value();
319 value.batched_commitments[1] = batched_commitments[1].get_value();
320
321 return value;
322 }
323 };
324
328
329 // \f$ \vec u = (u_0, ..., u_{d-1}) \f$
330 std::vector<FF> challenge;
331 // Evaluations at \f$ \vec u \f$ of the polynomials used in Sumcheck
333 // Full batched size
335
337 VerifierCommitments& commitments,
338 const std::shared_ptr<Transcript>& transcript)
339 {
340 auto generate_challenges = [&transcript]<size_t N>(const std::string& label) -> std::array<FF, N> {
342 for (size_t idx = 0; idx < labels.size(); idx++) {
343 labels[idx] = label + std::to_string(idx);
344 }
345
346 std::array<FF, N> challenges;
347 challenges = transcript->template get_challenges<FF>(labels);
348
349 return challenges;
350 };
351
352 auto compute_batched_evaluation = []<size_t N>(RefArray<FF, N> claimed_evaluations,
353 RefArray<FF, N> challenges) {
354 FF result(0);
355 for (auto [eval, challenge] : zip_view(claimed_evaluations, challenges)) {
356 result += eval * challenge;
357 }
358 return result;
359 };
360
361 auto compute_batched_commitment = []<size_t N>(RefArray<Commitment, N> commitments,
362 RefArray<FF, N> challenges) {
363 std::vector<Commitment> points;
364 std::vector<FF> scalars;
365 size_t idx = 0;
366 for (auto [commitment, scalar] : zip_view(commitments, challenges)) {
367 if (commitment.is_point_at_infinity()) {
368 info("Commitment at index ", idx, " is zero");
369 }
370 points.emplace_back(commitment);
371 scalars.emplace_back(scalar);
372 idx++;
373 }
374 return batch_mul_native(points, scalars);
375 };
376
377 // Generate challenges to batch shifted and unshifted polynomials/evaluation
378 auto unshifted_challenges =
379 generate_challenges.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>("unshifted_challenge_");
380 auto shifted_challenges =
381 generate_challenges.operator()<Flavor::NUM_SHIFTED_ENTITIES>("shifted_challenge_");
382
383 // Batch polynomials
384 auto unshifted = polynomials.get_unshifted();
385 auto shifted = polynomials.get_to_be_shifted();
386
387 auto batched_unshifted = PolynomialBatcher::compute_batched<Flavor::NUM_UNSHIFTED_ENTITIES>(
388 unshifted, full_batched_size, unshifted_challenges);
389 auto batched_shifted = PolynomialBatcher::compute_batched<Flavor::NUM_SHIFTED_ENTITIES>(
390 shifted, full_batched_size, shifted_challenges, true);
391
392 // Batch evaluations
393 auto unshifted_evaluations = claimed_evaluations.get_unshifted();
394 auto shifted_evaluations = claimed_evaluations.get_shifted();
395
396 auto batched_unshifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
397 unshifted_evaluations, unshifted_challenges);
398 auto batched_shifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
399 shifted_evaluations, shifted_challenges);
400
401 // Batch commitments
402 auto unshifted_commitments = commitments.get_unshifted();
403 auto shifted_commitments = commitments.get_to_be_shifted();
404 auto batched_unshifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
405 unshifted_commitments, unshifted_challenges);
406 auto batched_shifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
407 shifted_commitments, shifted_challenges);
408
409 return ProverAccumulator{
411 .batched_evaluations = { batched_unshifted_evaluation, batched_shifted_evaluation },
412 .batched_polynomials = { batched_unshifted, batched_shifted },
413 .batched_commitments = { batched_unshifted_commitment, batched_shifted_commitment },
414 .dyadic_size = full_batched_size,
415 };
416 }
417
418 VerifierAccumulator batch(const std::shared_ptr<VerifierInstance>& verifier_instance,
419 const std::shared_ptr<Transcript>& transcript)
420 {
421 auto generate_challenges = [&transcript]<size_t N>(const std::string& label) -> std::array<FF, N> {
423 for (size_t idx = 0; idx < labels.size(); idx++) {
424 labels[idx] = label + std::to_string(idx);
425 }
426
427 std::array<FF, N> challenges;
428 challenges = transcript->template get_challenges<FF>(labels);
429
430 return challenges;
431 };
432
433 auto compute_batched_evaluation = []<size_t N>(RefArray<FF, N> claimed_evaluations,
434 RefArray<FF, N> challenges) {
435 FF result(0);
436 for (auto [eval, challenge] : zip_view(claimed_evaluations, challenges)) {
437 result += eval * challenge;
438 }
439 return result;
440 };
441
442 auto compute_batched_commitment = []<size_t N>(RefArray<Commitment, N> commitments,
443 RefArray<FF, N> challenges) {
444 std::vector<Commitment> points;
445 std::vector<FF> scalars;
446 for (auto [commitment, scalar] : zip_view(commitments, challenges)) {
447 points.emplace_back(commitment);
448 scalars.emplace_back(scalar);
449 }
450 return batch_mul_native(points, scalars);
451 };
452
453 // NOTE: THIS MIGHT BE SLOW!!!!!!
454 Flavor::VerifierCommitments verifier_commitments(verifier_instance->vk,
455 verifier_instance->witness_commitments);
456
457 // Generate challenges to batch shifted and unshifted polynomials/evaluation
458 auto unshifted_challenges =
459 generate_challenges.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>("unshifted_challenge_");
460 auto shifted_challenges =
461 generate_challenges.operator()<Flavor::NUM_SHIFTED_ENTITIES>("shifted_challenge_");
462
463 // Batch evaluations
464 auto unshifted_evaluations = claimed_evaluations.get_unshifted();
465 auto shifted_evaluations = claimed_evaluations.get_to_be_shifted();
466
467 auto batched_unshifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
468 unshifted_evaluations, unshifted_challenges);
469 auto batched_shifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
470 shifted_evaluations, shifted_challenges);
471
472 // Batch commitments
473 auto unshifted_commitments = verifier_commitments.get_unshifted();
474 auto shifted_commitments = verifier_commitments.get_to_be_shifted();
475 auto batched_unshifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
476 unshifted_commitments, unshifted_challenges);
477 auto batched_shifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
478 shifted_commitments, shifted_challenges);
479
480 return VerifierAccumulator{
482 .batched_evaluations = { batched_unshifted_evaluation, batched_shifted_evaluation },
483 .batched_commitments = { batched_unshifted_commitment, batched_shifted_commitment }
484 };
485 }
486 };
487
490
491 // \f$ \vec u = (u_0, ..., u_{d-1}) \f$
492 std::vector<StdlibFF> challenge;
493 // Evaluations at \f$ \vec u \f$ of the polynomials used in Sumcheck
495
498 {
499 auto generate_challenges = [&transcript]<size_t N>(const std::string& label) -> std::array<StdlibFF, N> {
501 for (size_t idx = 0; idx < labels.size(); idx++) {
502 labels[idx] = label + std::to_string(idx);
503 }
504
505 std::array<StdlibFF, N> challenges;
506 challenges = transcript->template get_challenges<StdlibFF>(labels);
507
508 return challenges;
509 };
510
511 auto compute_batched_evaluation = []<size_t N>(RefArray<StdlibFF, N> claimed_evaluations,
512 RefArray<StdlibFF, N> challenges) {
513 StdlibFF result(0);
514 for (auto [eval, challenge] : zip_view(claimed_evaluations, challenges)) {
515 result += eval * challenge;
516 }
517 return result;
518 };
519
520 auto compute_batched_commitment = []<size_t N>(RefArray<RecursiveCommitment, N> commitments,
521 RefArray<StdlibFF, N> challenges) {
523 std::vector<StdlibFF> scalars;
524 for (auto [commitment, scalar] : zip_view(commitments, challenges)) {
525 if (commitment.is_point_at_infinity().get_value()) {
526 info("HELLO");
527 }
528 if (scalar.is_zero().get_value()) {
529 info("HELLO");
530 }
531 points.emplace_back(commitment);
532 scalars.emplace_back(scalar);
533 }
534 return RecursiveCommitment::batch_mul(points, scalars);
535 };
536
537 // NOTE: THIS MIGHT BE SLOW!!!!!!
538 RecursiveFlavor::VerifierCommitments verifier_commitments(verifier_instance->vk_and_hash->vk,
539 verifier_instance->witness_commitments);
540
541 // Generate challenges to batch shifted and unshifted polynomials/evaluation
542 auto unshifted_challenges =
543 generate_challenges.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>("unshifted_challenge_");
544 auto shifted_challenges =
545 generate_challenges.operator()<Flavor::NUM_SHIFTED_ENTITIES>("shifted_challenge_");
546
547 // Batch evaluations
548 auto unshifted_evaluations = claimed_evaluations.get_unshifted();
549 auto shifted_evaluations = claimed_evaluations.get_to_be_shifted();
550
551 auto batched_unshifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
552 unshifted_evaluations, unshifted_challenges);
553 auto batched_shifted_evaluation = compute_batched_evaluation.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
554 shifted_evaluations, shifted_challenges);
555
556 // Batch commitments
557 auto unshifted_verifier_commitments = verifier_commitments.get_unshifted();
558 auto shifted_witness_commitments = verifier_commitments.get_to_be_shifted();
559 auto batched_unshifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_UNSHIFTED_ENTITIES>(
560 unshifted_verifier_commitments, unshifted_challenges);
561 auto batched_shifted_commitment = compute_batched_commitment.operator()<Flavor::NUM_SHIFTED_ENTITIES>(
562 shifted_witness_commitments, shifted_challenges);
563
565 { batched_unshifted_evaluation, batched_shifted_evaluation },
566 { batched_unshifted_commitment, batched_shifted_commitment });
567 }
568 };
569
570 // Specifies proof type or equivalently the type of recursive verification to be performed on a given proof
571 enum class QUEUE_TYPE {
572 OINK,
573 PG,
574 PG_FINAL, // the final PG verification, used in hiding kernel
575 PG_TAIL, // used in tail to indicate special handling of merge for ZK
576 MEGA
577 };
578
579 // An entry in the native verification queue
581 std::vector<FF> proof; // oink or PG
584 bool is_kernel = false;
585 };
586 using VerificationQueue = std::deque<VerifierInputs>;
587
588 // An entry in the stdlib verification queue
590 StdlibProof proof; // oink or PG
591 std::shared_ptr<RecursiveVKAndHash> honk_vk_and_hash;
593 bool is_kernel = false;
594 };
595 using StdlibVerificationQueue = std::deque<StdlibVerifierInputs>;
596
597 private:
598 // Transcript for CIVC prover (shared between Hiding circuit, Merge, ECCVM, and Translator)
599 std::shared_ptr<Transcript> transcript = std::make_shared<Transcript>();
600
601 // Transcript to be shared across the folding of K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n}
603
604 size_t num_circuits; // total number of circuits to be accumulated in the IVC
605 public:
606 size_t num_circuits_accumulated = 0; // number of circuits accumulated so far
607
608 ProverAccumulator prover_accumulator; // current PG prover accumulator instance
609
610 HonkProof pcs_proof; // decider proof to be verified in the hiding circuit
611
612 VerifierAccumulator recursive_verifier_native_accum; // native verifier accumulator used in recursive folding
613 VerifierAccumulator native_verifier_accum; // native verifier accumulator used in prover folding
614
615 // Set of tuples {proof, verification_key, type (Oink/PG)} to be recursively verified
617 // Set of tuples {stdlib_proof, stdlib_verification_key, type} corresponding to the native verification queue
619
620 // Management of linking databus commitments between circuits in the IVC
622
624
626
627 size_t get_num_circuits() const { return num_circuits; }
628
629 // IVCBase interface
630 Goblin& get_goblin() override { return goblin; }
631 const Goblin& get_goblin() const override { return goblin; }
632
634
636 const std::vector<std::shared_ptr<RecursiveVKAndHash>>& input_keys = {});
637
638 [[nodiscard("Pairing points should be accumulated")]] std::
641 ClientCircuit& circuit,
642 const StdlibVerifierInputs& verifier_inputs,
643 const std::optional<RecursiveVerifierAccumulator>& input_verifier_accumulator,
644 const TableCommitments& T_prev_commitments,
645 const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript);
646
647 // Complete the logic of a kernel circuit (e.g. PG/merge recursive verification, databus consistency checks)
649
658 void accumulate(ClientCircuit& circuit, const std::shared_ptr<MegaVerificationKey>& precomputed_vk) override;
659
660 Proof prove();
661
663 static void hide_op_queue_content_in_tail(ClientCircuit& circuit);
665
666 static bool verify(const Proof& proof, const VerificationKey& vk);
667
668 HonkProof construct_pcs_proof(const std::shared_ptr<Transcript>& transcript);
669
670 VerificationKey get_vk() const;
671
672 private:
679 void update_native_verifier_accumulator(const VerifierInputs& queue_entry,
680 const std::shared_ptr<Transcript>& verifier_transcript);
681
682 static ProverAccumulator execute_first_sumcheck(const std::shared_ptr<ProverInstance>& prover_instance,
684 const std::shared_ptr<Transcript>& transcript);
685
686 static VerifierAccumulator execute_first_sumcheck_native_verification(
687 const std::shared_ptr<VerifierInstance>& verifier_instance,
688 const std::shared_ptr<Transcript>& transcript,
689 const HonkProof& proof);
690
691 HonkProof construct_sumcheck_proof(const std::shared_ptr<ProverInstance>& prover_instance,
693 const std::shared_ptr<Transcript>& transcript);
694
695 HonkProof construct_folding_proof(const std::shared_ptr<ProverInstance>& prover_instance,
697 const std::shared_ptr<Transcript>& transcript);
698
700 const std::shared_ptr<MegaVerificationKey>& verification_key);
701
703
704 static RecursiveVerifierAccumulator execute_first_sumcheck_recursive_verification(
705 ClientCircuit& circuit,
706 const std::shared_ptr<RecursiveVerifierInstance>& verifier_instance,
708 const StdlibProof& proof);
709
710 static RecursiveVerifierAccumulator perform_folding_recursive_verification(
711 ClientCircuit& circuit,
712 const std::optional<RecursiveVerifierAccumulator>& verifier_accumulator,
713 const std::shared_ptr<RecursiveVerifierInstance>& verifier_instance,
715 const StdlibProof& proof,
716 std::optional<StdlibFF>& prev_accum_hash,
717 bool is_kernel);
718};
719
720// Serialization methods for ClientIVC::VerificationKey
721inline void read(uint8_t const*& it, SumcheckClientIVC::VerificationKey& vk)
722{
723 using serialize::read;
724
725 size_t num_frs = SumcheckClientIVC::VerificationKey::calc_num_data_types();
726
727 // Read exactly num_frs field elements from the buffer
728 std::vector<bb::fr> field_elements(num_frs);
729 for (auto& element : field_elements) {
730 read(it, element);
731 }
732
733 // Then use from_field_elements to populate the verification key
734 vk.from_field_elements(field_elements);
735}
736
737inline void write(std::vector<uint8_t>& buf, SumcheckClientIVC::VerificationKey const& vk)
738{
739 using serialize::write;
740
741 // Convert to field elements and write them directly without length prefix
742 auto field_elements = vk.to_field_elements();
743 for (const auto& element : field_elements) {
744 write(buf, element);
745 }
746}
747
748} // namespace bb
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
CommitmentKey object over a pairing group 𝔾₁.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
Class responsible for computation of the batched multilinear polynomials required by the Gemini proto...
Definition gemini.hpp:129
static constexpr size_t PUBLIC_INPUTS_SIZE
Base class interface for IVC schemes.
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
A container for the prover polynomials handles.
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
Container for all witness polynomials used/constructed by the prover.
Curve::ScalarField FF
static constexpr size_t NUM_SHIFTED_ENTITIES
static constexpr size_t VIRTUAL_LOG_N
Curve::AffineElement Commitment
static constexpr size_t NUM_UNSHIFTED_ENTITIES
VerifierCommitments_< Commitment, VerificationKey > VerifierCommitments
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
The recursive counterpart to the "native" Mega flavor.
StdlibTranscript< CircuitBuilder > Transcript
typename Curve::Element Commitment
typename Curve::ScalarField FF
VKAndHash_< FF, VerificationKey > VKAndHash
MegaFlavor::WitnessEntities< Commitment > WitnessCommitments
A container for the witness commitments.
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n=MegaFlavor::VIRTUAL_LOG_N)
static size_t calc_num_data_types()
Calculate the number of field elements needed for serialization.
Definition flavor.hpp:181
Verifier class for all the presumcheck rounds, which are shared between the folding verifier and ultr...
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
A wrapper class for deserializing objects from the public inputs of a circuit.
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
The IVC scheme used by the aztec client for private function execution.
VerificationKey get_vk() const
MegaCircuitBuilder ClientCircuit
std::deque< VerifierInputs > VerificationQueue
static VerifierAccumulator execute_first_sumcheck_native_verification(const std::shared_ptr< VerifierInstance > &verifier_instance, const std::shared_ptr< Transcript > &transcript, const HonkProof &proof)
MegaFlavor::CommitmentKey bn254_commitment_key
std::shared_ptr< Transcript > prover_accumulation_transcript
Proof prove()
Construct a proof for the IVC, which, if verified, fully establishes its correctness.
static void hide_op_queue_accumulation_result(ClientCircuit &circuit)
Add a valid operation with random data to the op queue to prevent information leakage in Translator p...
stdlib::recursion::PairingPoints< ClientCircuit > PairingPoints
stdlib::Proof< ClientCircuit > StdlibProof
void instantiate_stdlib_verification_queue(ClientCircuit &circuit, const std::vector< std::shared_ptr< RecursiveVKAndHash > > &input_keys={})
Instantiate a stdlib verification queue for use in the kernel completion logic.
std::shared_ptr< Transcript > transcript
QUEUE_TYPE get_queue_type() const
Get queue type for the proof of a circuit about to be accumulated based on num circuits accumulated s...
VerifierAccumulator recursive_verifier_native_accum
static RecursiveVerifierAccumulator perform_folding_recursive_verification(ClientCircuit &circuit, const std::optional< RecursiveVerifierAccumulator > &verifier_accumulator, const std::shared_ptr< RecursiveVerifierInstance > &verifier_instance, const std::shared_ptr< RecursiveTranscript > &transcript, const StdlibProof &proof, std::optional< StdlibFF > &prev_accum_hash, bool is_kernel)
static bool verify(const Proof &proof, const VerificationKey &vk)
Goblin & get_goblin() override
std::array< RecursiveFlavor::Commitment, ClientCircuit::NUM_WIRES > TableCommitments
VerifierAccumulator native_verifier_accum
RecursiveFlavor::Commitment RecursiveCommitment
VerificationQueue verification_queue
const Goblin & get_goblin() const override
void update_native_verifier_accumulator(const VerifierInputs &queue_entry, const std::shared_ptr< Transcript > &verifier_transcript)
Runs either Oink or PG native verifier to update the native verifier accumulator.
RecursiveFlavor::FF StdlibFF
Flavor::Curve::AffineElement Point
ProverAccumulator prover_accumulator
HonkProof construct_sumcheck_proof(const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &honk_vk, const std::shared_ptr< Transcript > &transcript)
HonkProof construct_honk_proof_for_hiding_kernel(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &verification_key)
Construct a zero-knowledge proof for the hiding circuit, which recursively verifies the last folding,...
static ProverAccumulator execute_first_sumcheck(const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &honk_vk, const std::shared_ptr< Transcript > &transcript)
std::tuple< std::optional< RecursiveVerifierAccumulator >, PairingPoints, TableCommitments > perform_recursive_verification_and_databus_consistency_checks(ClientCircuit &circuit, const StdlibVerifierInputs &verifier_inputs, const std::optional< RecursiveVerifierAccumulator > &input_verifier_accumulator, const TableCommitments &T_prev_commitments, const std::shared_ptr< RecursiveTranscript > &accumulation_recursive_transcript)
Populate the provided circuit with constraints for (1) recursive verification of the provided accumul...
HonkProof construct_folding_proof(const std::shared_ptr< ProverInstance > &prover_instance, const std::shared_ptr< MegaVerificationKey > &honk_vk, const std::shared_ptr< Transcript > &transcript)
Flavor::Commitment Commitment
HonkProof construct_pcs_proof(const std::shared_ptr< Transcript > &transcript)
Internal method for constructing a decider proof.
StdlibVerificationQueue stdlib_verification_queue
void accumulate(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
Perform prover work for accumulation (e.g. PG folding, merge proving)
static void hide_op_queue_content_in_tail(ClientCircuit &circuit)
Adds three random ops to the tail kernel.
std::deque< StdlibVerifierInputs > StdlibVerificationQueue
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
static RecursiveVerifierAccumulator execute_first_sumcheck_recursive_verification(ClientCircuit &circuit, const std::shared_ptr< RecursiveVerifierInstance > &verifier_instance, const std::shared_ptr< RecursiveTranscript > &transcript, const StdlibProof &proof)
static void hide_op_queue_content_in_hiding(ClientCircuit &circuit)
Adds two random ops to the hiding kernel.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
The VerifierInstance encapsulates all the necessary information for a Mega Honk Verifier to verify a ...
Manages the data that is propagated on the public inputs of an application/function circuit.
Manages the data that is propagated on the public inputs of a hiding kernel circuit.
Manages the data that is propagated on the public inputs of a kernel circuit.
The stdlib counterpart of VerifierInstance, used in recursive folding verification.
void info(Args... args)
Definition log.hpp:74
AluTraceBuilder builder
Definition alu.test.cpp:123
uint8_t const * buf
Definition data_store.hpp:9
uint8_t buffer[RANDOM_BUFFER_SIZE]
Definition engine.cpp:34
UltraKeccakFlavor::VerificationKey VerificationKey
DefaultIO< MegaCircuitBuilder > AppIO
The data that is propagated on the public inputs of an application/function circuit.
Entry point for Barretenberg command-line interface.
std::vector< fr > HonkProof
Definition proof.hpp:15
void write(std::vector< uint8_t > &buf, ClientIVC::VerificationKey const &vk)
void read(uint8_t const *&it, ClientIVC::VerificationKey &vk)
BaseTranscript< FrCodec, bb::crypto::Poseidon2< bb::crypto::Poseidon2Bn254ScalarFieldParams > > NativeTranscript
MegaCircuitBuilder_< field< Bn254FrParams > > MegaCircuitBuilder
VerifierCommitmentKey< Curve > vk
void read(auto &it, msgpack_concepts::HasMsgPack auto &obj)
Automatically derived read for any object that defines .msgpack() (implicitly defined by MSGPACK_FIEL...
void write(auto &buf, const msgpack_concepts::HasMsgPack auto &obj)
Automatically derived write for any object that defines .msgpack() (implicitly defined by MSGPACK_FIE...
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
VerifierAccumulator batch(const std::shared_ptr< VerifierInstance > &verifier_instance, const std::shared_ptr< Transcript > &transcript)
ProverAccumulator batch(ProverPolynomials &polynomials, VerifierCommitments &commitments, const std::shared_ptr< Transcript > &transcript)
A full proof for the IVC scheme containing a Mega proof showing correctness of the hiding circuit (wh...
static constexpr size_t PROOF_LENGTH(size_t virtual_log_n=MegaZKFlavor::VIRTUAL_LOG_N)
The size of a ClientIVC proof with backend-added public inputs: HidingKernelIO.
MSGPACK_FIELDS(mega_proof, goblin_proof)
static Proof from_msgpack_buffer(uint8_t const *&buffer)
static Proof from_file_msgpack(const std::string &filename)
static Proof from_field_elements(const std::vector< SumcheckClientIVC::FF > &fields)
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n=MegaZKFlavor::VIRTUAL_LOG_N)
The size of a ClientIVC proof without backend-added public inputs.
static constexpr const char MSGPACK_SCHEMA_NAME[]
msgpack::sbuffer to_msgpack_buffer() const
std::vector< FF > to_field_elements() const
Serialize proof to field elements.
void to_file_msgpack(const std::string &filename) const
uint8_t * to_msgpack_heap_buffer() const
Very quirky method to convert a msgpack buffer to a "heap" buffer.
bool operator==(const Proof &other) const =default
std::array< Polynomial< FF >, 2 > batched_polynomials
RecursiveVerifierAccumulator batch(const std::shared_ptr< RecursiveVerifierInstance > &verifier_instance, const std::shared_ptr< RecursiveTranscript > &transcript)
StdlibFF hash_through_transcript(const std::string &domain_separator, RecursiveTranscript &transcript) const
RecursiveVerifierAccumulator(const std::vector< StdlibFF > &challenge, const std::array< StdlibFF, 2 > &batched_evaluations, const std::array< RecursiveCommitment, 2 > &batched_commitments)
RecursiveVerifierAccumulator(ClientCircuit *builder, VerifierAccumulator &native_accumulator)
std::array< RecursiveCommitment, 2 > batched_commitments
std::shared_ptr< RecursiveVKAndHash > honk_vk_and_hash
std::shared_ptr< ECCVMVerificationKey > eccvm
std::vector< bb::fr > to_field_elements() const
Serialize verification key to field elements.
std::shared_ptr< MegaVerificationKey > mega
size_t from_field_elements(std::span< const bb::fr > elements)
Deserialize verification key from field elements.
static size_t calc_num_data_types()
Calculate the number of field elements needed for serialization.
std::shared_ptr< TranslatorVerificationKey > translator
FF hash_through_transcript(const std::string &domain_separator, Transcript &transcript) const
std::shared_ptr< MegaVerificationKey > honk_vk
An object storing two EC points that represent the inputs to a pairing check.