Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
hypernova_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
8
9namespace bb {
10
11template <typename Flavor>
15{
16 BB_BENCH();
17
18 // Generate challenges to batch shifted and unshifted polynomials/commitments/evaluation
20 std::array<std::string, NUM_SHIFTED_ENTITIES> labels_shifted_witnesses;
21 for (size_t idx = 0; idx < NUM_UNSHIFTED_ENTITIES; idx++) {
22 labels_unshifted_entities[idx] = "unshifted_challenge_" + std::to_string(idx);
23 }
24 for (size_t idx = 0; idx < NUM_SHIFTED_ENTITIES; idx++) {
25 labels_shifted_witnesses[idx] = "shifted_challenge_" + std::to_string(idx);
26 }
27 auto unshifted_challenges = transcript->template get_challenges<FF>(labels_unshifted_entities);
28 auto shifted_challenges = transcript->template get_challenges<FF>(labels_shifted_witnesses);
29
30 // Batch evaluations
31 FF batched_unshifted_evaluation(0);
32 FF batched_shifted_evaluation(0);
33
34 for (auto [eval, challenge] : zip_view(sumcheck_output.claimed_evaluations.get_unshifted(), unshifted_challenges)) {
35 batched_unshifted_evaluation += eval * challenge;
36 }
37 for (auto [eval, challenge] : zip_view(sumcheck_output.claimed_evaluations.get_shifted(), shifted_challenges)) {
38 batched_shifted_evaluation += eval * challenge;
39 }
40
41 // Batch commitments
42 VerifierCommitments verifier_commitments(instance->get_vk(), instance->witness_commitments);
43
44 Commitment batched_unshifted_commitment;
45 Commitment batched_shifted_commitment;
46
47 std::vector<Commitment> points;
48 std::vector<FF> scalars;
49 for (auto [commitment, scalar] : zip_view(verifier_commitments.get_unshifted(), unshifted_challenges)) {
50 points.emplace_back(commitment);
51 scalars.emplace_back(scalar);
52 }
53 batched_unshifted_commitment = batch_mul(points, scalars);
54
55 points.clear();
56 scalars.clear();
57 for (auto [commitment, scalar] : zip_view(verifier_commitments.get_to_be_shifted(), shifted_challenges)) {
58 points.emplace_back(commitment);
59 scalars.emplace_back(scalar);
60 }
61 batched_shifted_commitment = batch_mul(points, scalars);
62
63 return Accumulator{
64 .challenge = sumcheck_output.challenge,
65 .shifted_evaluation = batched_shifted_evaluation,
66 .non_shifted_evaluation = batched_unshifted_evaluation,
67 .non_shifted_commitment = batched_unshifted_commitment,
68 .shifted_commitment = batched_shifted_commitment,
69 };
70};
71
72template <typename Flavor>
75 const Proof& proof)
76{
77 BB_BENCH();
78
79 vinfo("HypernovaFoldingVerifier: verifying Oink proof...");
80 // Complete the incoming verifier instance
81 OinkVerifier verifier{ instance, transcript };
82 transcript->load_proof(proof);
83 verifier.verify();
84
85 if constexpr (IsRecursiveFlavor<Flavor>) {
86 instance->target_sum = FF::from_witness_index(instance->builder, instance->builder->zero_idx());
87 } else {
88 instance->target_sum = FF::zero();
89 }
90 instance->gate_challenges = transcript->template get_powers_of_challenge<FF>(
91 "HypernovaFoldingProver:gate_challenge", Flavor::VIRTUAL_LOG_N);
92
93 // Sumcheck verification
94 vinfo("HypernovaFoldingVerifier: verifying Sumcheck to turn instance into an accumulator...");
95 std::vector<FF> padding_indicator_array(Flavor::VIRTUAL_LOG_N, 1);
96 SumcheckVerifier sumcheck(transcript, instance->alphas, Flavor::VIRTUAL_LOG_N, instance->target_sum);
97 SumcheckOutput<Flavor> sumcheck_output =
98 sumcheck.verify(instance->relation_parameters, instance->gate_challenges, padding_indicator_array);
99
101 sumcheck_output.verified,
102 true,
103 "HypernovaFoldingVerifier: Failed to recursively verify Sumcheck to turn instance into an accumulator.");
104
105 auto accumulator = sumcheck_output_to_accumulator(sumcheck_output, instance);
106
107 vinfo("HypernovaFoldingVerifier: Successfully turned instance into accumulator.");
108
109 return { sumcheck_output.verified, accumulator };
110};
111
112template <typename Flavor>
116{
117 BB_BENCH();
118
119 vinfo("HypernovaFoldingVerifier: verifying folding proof...");
120
121 auto [sumcheck_result, incoming_accumulator] = instance_to_accumulator(instance, proof);
122
123 MultilinearBatchingVerifier batching_verifier(transcript);
124 auto [sumcheck_batching_result, new_accumulator] = batching_verifier.verify_proof();
125 BB_ASSERT_EQ(sumcheck_batching_result,
126 true,
127 "HypernovaFoldingVerifier: Failed to recursively verify Sumcheck to batch two accumulators.");
128
129 vinfo("HypernovaFoldingVerifier: successfully verified folding proof.");
130
131 return { sumcheck_result, sumcheck_batching_result, new_accumulator };
132};
133
136} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:88
#define BB_BENCH()
Definition bb_bench.hpp:222
std::conditional_t< IsRecursiveFlavor< Flavor >, typename HypernovaRecursiveTypes::Proof, typename HypernovaNativeTypes::Proof > Proof
OinkVerifier< Flavor > OinkVerifier
std::pair< bool, Accumulator > instance_to_accumulator(const std::shared_ptr< VerifierInstance > &instance, const Proof &proof)
Turn an instance into an accumulator by executing sumcheck.
std::conditional_t< IsRecursiveFlavor< Flavor >, typename HypernovaRecursiveTypes::MultilinearBatchingVerifier, typename HypernovaNativeTypes::MultilinearBatchingVerifier > MultilinearBatchingVerifier
Accumulator sumcheck_output_to_accumulator(MegaSumcheckOutput &sumcheck_output, const std::shared_ptr< VerifierInstance > &instance)
static constexpr size_t VIRTUAL_LOG_N
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
Definition sumcheck.hpp:698
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, std::vector< FF > &gate_challenges, const std::vector< FF > &padding_indicator_array)
Extract round univariate, check sum, generate challenge, compute next target sum.....
Definition sumcheck.hpp:771
#define vinfo(...)
Definition log.hpp:79
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
ClaimedEvaluations claimed_evaluations
std::vector< FF > challenge
static constexpr field zero()