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 : key(std::make_shared<RecursiveDeciderVK>(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 = static_cast<uint32_t>(key->vk_and_hash->vk->num_public_inputs.get_value());
50
51 StdlibProof ipa_proof;
52 StdlibProof honk_proof;
53 if constexpr (HasIPAAccumulator<Flavor>) {
54 const size_t HONK_PROOF_LENGTH = Flavor::NativeFlavor::PROOF_LENGTH_WITHOUT_PUB_INPUTS() - IPA_PROOF_LENGTH;
55 // The extra calculation is for the IPA proof length.
56 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1182): Handle in ProofSurgeon.
57 BB_ASSERT_EQ(proof.size(), HONK_PROOF_LENGTH + IPA_PROOF_LENGTH + num_public_inputs);
58 // split out the ipa proof
59 const std::ptrdiff_t honk_proof_with_pub_inputs_length =
60 static_cast<std::ptrdiff_t>(HONK_PROOF_LENGTH + num_public_inputs);
61 ipa_proof = StdlibProof(proof.begin() + honk_proof_with_pub_inputs_length, proof.end());
62 honk_proof = StdlibProof(proof.begin(), proof.begin() + honk_proof_with_pub_inputs_length);
63 } else {
64 honk_proof = proof;
65 }
66 transcript->load_proof(honk_proof);
67 OinkVerifier oink_verifier{ builder, key, transcript };
68 oink_verifier.verify();
69 const std::vector<FF>& public_inputs = key->public_inputs;
70
71 VerifierCommitments commitments{ key->vk_and_hash->vk, key->witness_commitments };
72 static constexpr size_t VIRTUAL_LOG_N = Flavor::NativeFlavor::VIRTUAL_LOG_N;
73 // Get the gate challenges for sumcheck computation
74 key->gate_challenges = transcript->template get_powers_of_challenge<FF>("Sumcheck:gate_challenge", VIRTUAL_LOG_N);
75
76 // Execute Sumcheck Verifier and extract multivariate opening point u = (u_0, ..., u_{d-1}) and purported
77 // multivariate evaluations at u
78
79 std::vector<FF> padding_indicator_array(VIRTUAL_LOG_N, 1);
80 if constexpr (Flavor::HasZK) {
81 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1521): ZK Recursive verifiers need to evaluate
82 // RowDisablingPolynomial, which requires knowing the actual `log_circuit_size`. Can be fixed by reserving the
83 // first rows of the trace for masking.
84 padding_indicator_array =
85 compute_padding_indicator_array<Curve, VIRTUAL_LOG_N>(key->vk_and_hash->vk->log_circuit_size);
86 }
87
88 Sumcheck sumcheck(transcript, key->alphas, VIRTUAL_LOG_N);
89
90 // Receive commitments to Libra masking polynomials
92 if constexpr (Flavor::HasZK) {
93 libra_commitments[0] = transcript->template receive_from_prover<Commitment>("Libra:concatenation_commitment");
94 }
95 SumcheckOutput<Flavor> sumcheck_output =
96 sumcheck.verify(key->relation_parameters, key->gate_challenges, padding_indicator_array);
97
98 // For MegaZKFlavor: the sumcheck output contains claimed evaluations of the Libra polynomials
99 if constexpr (Flavor::HasZK) {
100 libra_commitments[1] = transcript->template receive_from_prover<Commitment>("Libra:grand_sum_commitment");
101 libra_commitments[2] = transcript->template receive_from_prover<Commitment>("Libra:quotient_commitment");
102 }
103 // Execute Shplemini to produce a batch opening claim subsequently verified by a univariate PCS
104 bool consistency_checked = true;
105 ClaimBatcher claim_batcher{
106 .unshifted = ClaimBatch{ commitments.get_unshifted(), sumcheck_output.claimed_evaluations.get_unshifted() },
107 .shifted = ClaimBatch{ commitments.get_to_be_shifted(), sumcheck_output.claimed_evaluations.get_shifted() }
108 };
109 const BatchOpeningClaim<Curve> opening_claim =
110 Shplemini::compute_batch_opening_claim(padding_indicator_array,
111 claim_batcher,
112 sumcheck_output.challenge,
113 Commitment::one(builder),
114 transcript,
117 &consistency_checked,
118 libra_commitments,
119 sumcheck_output.claimed_libra_evaluation);
120
121 auto pairing_points = PCS::reduce_verify_batch_opening_claim(opening_claim, transcript);
122
123 // Reconstruct the public inputs
124 IO inputs;
125 inputs.reconstruct_from_public(public_inputs);
126
127 // Construct output
128 Output output(inputs);
129 output.ipa_proof = ipa_proof; // Add IPA proof
130
131 // Aggregate new pairing point with the ones reconstructed from the public inputs
132 output.points_accumulator.aggregate(pairing_points);
133
134 return output;
135}
136
146
147// UltraRecursiveFlavor_ specializations
150 verify_proof<DefaultIO<UltraCircuitBuilder>>(
152
155 verify_proof<DefaultIO<MegaCircuitBuilder>>(
157
158// UltraZKRecursiveFlavor_ specializations
161 verify_proof<DefaultIO<UltraCircuitBuilder>>(
163
166 verify_proof<DefaultIO<MegaCircuitBuilder>>(
168
169// UltraRollupRecursiveFlavor_ specialization
172 verify_proof<RollupIO>(
174
175// MegaRecursiveFlavor_ specialization with DefaultIO
178 verify_proof<DefaultIO<UltraCircuitBuilder>>(
180
183 verify_proof<DefaultIO<MegaCircuitBuilder>>(
185
186// MegaZKRecursiveFlavor_ specialization with DefaultIO
189 verify_proof<DefaultIO<UltraCircuitBuilder>>(
191
194 verify_proof<DefaultIO<MegaCircuitBuilder>>(
196
197// ClientIVC specialization
200 verify_proof<HidingKernelIO<UltraCircuitBuilder>>(
202
203// GoblinAvm specialization
206 verify_proof<GoblinAvmIO<UltraCircuitBuilder>>(
208
209} // namespace bb::stdlib::recursion::honk
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
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.
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:645
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 DeciderVerificationKey, 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.