Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_recursive_verifier.cpp
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
17
19
20template <typename Flavor>
22 const std::shared_ptr<VKAndHash>& vk_and_hash,
23 const std::shared_ptr<Transcript>& transcript)
24 : verifier_instance(std::make_shared<RecursiveVerifierInstance>(builder, vk_and_hash))
26 , transcript(transcript)
27{}
28
35template <typename Flavor>
36template <class IO>
38 const stdlib::Proof<Builder>& proof)
39{
40 using Sumcheck = ::bb::SumcheckVerifier<Flavor>;
41 using PCS = typename Flavor::PCS;
42 using Curve = typename Flavor::Curve;
43 using Shplemini = ::bb::ShpleminiVerifier_<Curve>;
44 using VerifierCommitments = typename Flavor::VerifierCommitments;
45 using ClaimBatcher = ClaimBatcher_<Curve>;
46 using ClaimBatch = ClaimBatcher::Batch;
47
48 const size_t num_public_inputs =
49 static_cast<uint32_t>(verifier_instance->vk_and_hash->vk->num_public_inputs.get_value());
51
52 StdlibProof ipa_proof;
53 StdlibProof honk_proof;
54 if constexpr (HasIPAAccumulator<Flavor>) {
55 const size_t HONK_PROOF_LENGTH = Flavor::NativeFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS() - IPA_PROOF_LENGTH;
56 // The extra calculation is for the IPA proof length.
57 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1182): Handle in ProofSurgeon.
58 BB_ASSERT_EQ(proof.size(), HONK_PROOF_LENGTH + IPA_PROOF_LENGTH + num_public_inputs);
59 // split out the ipa proof
60 const std::ptrdiff_t honk_proof_with_pub_inputs_length =
61 static_cast<std::ptrdiff_t>(HONK_PROOF_LENGTH + num_public_inputs);
62 ipa_proof = StdlibProof(proof.begin() + honk_proof_with_pub_inputs_length, proof.end());
63 honk_proof = StdlibProof(proof.begin(), proof.begin() + honk_proof_with_pub_inputs_length);
64 } else {
65 honk_proof = proof;
66 }
67 transcript->load_proof(honk_proof);
68 OinkVerifier oink_verifier{ verifier_instance, transcript };
69 oink_verifier.verify();
70 const std::vector<FF>& public_inputs = verifier_instance->public_inputs;
71
72 VerifierCommitments commitments{ verifier_instance->vk_and_hash->vk, verifier_instance->witness_commitments };
73 static constexpr size_t VIRTUAL_LOG_N = Flavor::NativeFlavor::VIRTUAL_LOG_N;
74 // Get the gate challenges for sumcheck computation
75 verifier_instance->gate_challenges =
76 transcript->template get_powers_of_challenge<FF>("Sumcheck:gate_challenge", VIRTUAL_LOG_N);
77
78 // Execute Sumcheck Verifier and extract multivariate opening point u = (u_0, ..., u_{d-1}) and purported
79 // multivariate evaluations at u
80
81 std::vector<FF> padding_indicator_array(VIRTUAL_LOG_N, 1);
82 if constexpr (Flavor::HasZK) {
83 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1521): ZK Recursive verifiers need to evaluate
84 // RowDisablingPolynomial, which requires knowing the actual `log_circuit_size`. Can be fixed by reserving the
85 // first rows of the trace for masking.
86 padding_indicator_array =
87 compute_padding_indicator_array<Curve, VIRTUAL_LOG_N>(verifier_instance->vk_and_hash->vk->log_circuit_size);
88 }
89
90 Sumcheck sumcheck(transcript, verifier_instance->alphas, VIRTUAL_LOG_N);
91
92 // Receive commitments to Libra masking polynomials
94 if constexpr (Flavor::HasZK) {
95 libra_commitments[0] = transcript->template receive_from_prover<Commitment>("Libra:concatenation_commitment");
96 }
97 SumcheckOutput<Flavor> sumcheck_output = sumcheck.verify(
98 verifier_instance->relation_parameters, verifier_instance->gate_challenges, padding_indicator_array);
99
100 // For MegaZKFlavor: the sumcheck output contains claimed evaluations of the Libra polynomials
101 if constexpr (Flavor::HasZK) {
102 libra_commitments[1] = transcript->template receive_from_prover<Commitment>("Libra:grand_sum_commitment");
103 libra_commitments[2] = transcript->template receive_from_prover<Commitment>("Libra:quotient_commitment");
104 }
105 // Execute Shplemini to produce a batch opening claim subsequently verified by a univariate PCS
106 bool consistency_checked = true;
107 ClaimBatcher claim_batcher{
108 .unshifted = ClaimBatch{ commitments.get_unshifted(), sumcheck_output.claimed_evaluations.get_unshifted() },
109 .shifted = ClaimBatch{ commitments.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_shifted() }
110 };
111 const BatchOpeningClaim<Curve> opening_claim =
112 Shplemini::compute_batch_opening_claim(padding_indicator_array,
113 claim_batcher,
114 sumcheck_output.challenge,
115 Commitment::one(builder),
116 transcript,
119 &consistency_checked,
120 libra_commitments,
121 sumcheck_output.claimed_libra_evaluation);
122
123 auto pairing_points = PCS::reduce_verify_batch_opening_claim(opening_claim, transcript);
124
125 // Reconstruct the public inputs
126 IO inputs;
127 inputs.reconstruct_from_public(public_inputs);
128
129 // Construct output
130 Output output(inputs);
131 output.ipa_proof = ipa_proof; // Add IPA proof
132
133 // Aggregate new pairing point with the ones reconstructed from the public inputs
134 output.points_accumulator.aggregate(pairing_points);
135
136 return output;
137}
138
148
149// UltraRecursiveFlavor_ specializations
152 verify_proof<DefaultIO<UltraCircuitBuilder>>(
154
157 verify_proof<DefaultIO<MegaCircuitBuilder>>(
159
160// UltraZKRecursiveFlavor_ specializations
163 verify_proof<DefaultIO<UltraCircuitBuilder>>(
165
168 verify_proof<DefaultIO<MegaCircuitBuilder>>(
170
171// UltraRollupRecursiveFlavor_ specialization
174 verify_proof<RollupIO>(
176
177// MegaRecursiveFlavor_ specialization with DefaultIO
180 verify_proof<DefaultIO<UltraCircuitBuilder>>(
182
185 verify_proof<DefaultIO<MegaCircuitBuilder>>(
187
188// MegaZKRecursiveFlavor_ specialization with DefaultIO
191 verify_proof<DefaultIO<UltraCircuitBuilder>>(
193
196 verify_proof<DefaultIO<MegaCircuitBuilder>>(
198
199// ClientIVC specialization
202 verify_proof<HidingKernelIO<UltraCircuitBuilder>>(
204
205// GoblinAvm specialization
208 verify_proof<GoblinAvmIO<UltraCircuitBuilder>>(
210
211} // namespace bb::stdlib::recursion::honk
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:88
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
curve::BN254 Curve
static constexpr bool HasZK
static constexpr size_t VIRTUAL_LOG_N
KZG< Curve > PCS
VerifierCommitments_< Commitment, VerificationKey > VerifierCommitments
The recursive counterpart to the "native" Mega flavor.
The recursive counterpart to the "native" MegaZKFlavor.
Verifier class for all the presumcheck rounds, which are shared between the folding verifier and ultr...
void verify()
Oink Verifier function that runs all the rounds of the verifier.
An efficient verifier for the evaluation proofs of multilinear polynomials and their shifts.
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:698
The recursive counterpart to the "native" Ultra flavor.
The recursive counterpart to the "native" UltraRollupFlavor.
The recursive counterpart to the Ultra flavor with ZK.
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
The stdlib counterpart of VerifierInstance, used in recursive folding verification.
UltraRecursiveVerifier_(Builder *builder, const std::shared_ptr< VKAndHash > &vk_and_hash, const std::shared_ptr< Transcript > &transcript=std::make_shared< Transcript >())
Output verify_proof(const StdlibProof &proof)
AluTraceBuilder builder
Definition alu.test.cpp:123
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
stdlib::Proof< Builder > StdlibProof
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
For a small integer N = virtual_log_n and a given witness x = log_n, compute in-circuit an indicator_...
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:169
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
ClaimedEvaluations claimed_evaluations
std::vector< FF > challenge
void aggregate(PairingPoints const &other)
Compute a linear combination of the present pairing points with an input set of pairing points.