Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
merge_verifier.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
15
16namespace bb {
17
23template <typename Curve> class MergeVerifier_ {
24 public:
25 using FF = typename Curve::ScalarField;
27 using GroupElement = typename Curve::Element;
31 using Proof = std::vector<FF>; // Native: std::vector<bb::fr>, Recursive: stdlib::Proof<Builder>
33
34 // Number of columns that jointly constitute the op_queue, should be the same as the number of wires in the
35 // MegaCircuitBuilder
37 static constexpr bool IsRecursive = Curve::is_stdlib_type;
38
39 // Size of batch opening claim: [Q], [L₁..L₄], [R₁..R₄], [M₁..M₄], [G], [1]
40 static constexpr size_t MERGE_BATCHED_CLAIM_SIZE = (3 * NUM_WIRES) + 3;
41
42 using TableCommitments = std::array<Commitment, NUM_WIRES>; // Commitments to the subtables and the merged table
43
54
65
67 std::shared_ptr<Transcript> transcript;
68
74
83 [[nodiscard("Verification result should be checked")]] VerificationResult verify_proof(
84 const Proof& proof, const InputCommitments& input_commitments);
85
86 private:
87 std::vector<std::string> labels_degree_check = { "LEFT_TABLE_DEGREE_CHECK_0",
88 "LEFT_TABLE_DEGREE_CHECK_1",
89 "LEFT_TABLE_DEGREE_CHECK_2",
90 "LEFT_TABLE_DEGREE_CHECK_3" };
91
92 std::vector<std::string> labels_shplonk_batching_challenges = {
93 "SHPLONK_MERGE_BATCHING_CHALLENGE_0", "SHPLONK_MERGE_BATCHING_CHALLENGE_1",
94 "SHPLONK_MERGE_BATCHING_CHALLENGE_2", "SHPLONK_MERGE_BATCHING_CHALLENGE_3",
95 "SHPLONK_MERGE_BATCHING_CHALLENGE_4", "SHPLONK_MERGE_BATCHING_CHALLENGE_5",
96 "SHPLONK_MERGE_BATCHING_CHALLENGE_6", "SHPLONK_MERGE_BATCHING_CHALLENGE_7",
97 "SHPLONK_MERGE_BATCHING_CHALLENGE_8", "SHPLONK_MERGE_BATCHING_CHALLENGE_9",
98 "SHPLONK_MERGE_BATCHING_CHALLENGE_10", "SHPLONK_MERGE_BATCHING_CHALLENGE_11",
99 "SHPLONK_MERGE_BATCHING_CHALLENGE_12"
100 };
101
102 bool check_concatenation_identities(std::vector<FF>& evals, const FF& pow_kappa) const;
103
104 bool check_degree_identity(std::vector<FF>& evals,
105 const FF& pow_kappa_minus_one,
106 const std::vector<FF>& degree_check_challenges) const;
107
108 BatchOpeningClaim<Curve> compute_shplonk_opening_claim(const std::vector<Commitment>& table_commitments,
109 const Commitment& shplonk_batched_quotient,
110 const FF& shplonk_opening_challenge,
111 const std::vector<FF>& shplonk_batching_challenges,
112 const FF& kappa,
113 const FF& kappa_inv,
114 const std::vector<FF>& evals) const;
115};
116
117// Type aliases for convenience
119
120namespace stdlib::recursion::goblin {
121template <typename Builder> using MergeRecursiveVerifier = MergeVerifier_<bn254<Builder>>;
122} // namespace stdlib::recursion::goblin
123
124} // namespace bb
static constexpr size_t NUM_WIRES
Defines the circuit block types for the Mega arithmetization.
Unified verifier class for the Goblin ECC op queue transcript merge protocol.
static constexpr bool IsRecursive
typename Curve::AffineElement Commitment
typename Curve::ScalarField FF
std::shared_ptr< Transcript > transcript
typename Curve::Element GroupElement
BatchOpeningClaim< Curve > compute_shplonk_opening_claim(const std::vector< Commitment > &table_commitments, const Commitment &shplonk_batched_quotient, const FF &shplonk_opening_challenge, const std::vector< FF > &shplonk_batching_challenges, const FF &kappa, const FF &kappa_inv, const std::vector< FF > &evals) const
std::vector< FF > Proof
TranscriptFor_t< Curve > Transcript
MergeVerifier_(const MergeSettings settings=MergeSettings::PREPEND, std::shared_ptr< Transcript > transcript=std::make_shared< Transcript >())
bool check_concatenation_identities(std::vector< FF > &evals, const FF &pow_kappa) const
std::conditional_t< Curve::is_stdlib_type, stdlib::recursion::PairingPoints< Curve >, bb::PairingPoints< Curve > > PairingPoints
std::vector< std::string > labels_degree_check
static constexpr size_t MERGE_BATCHED_CLAIM_SIZE
VerificationResult verify_proof(const Proof &proof, const InputCommitments &input_commitments)
Verify the merge proof.
bool check_degree_identity(std::vector< FF > &evals, const FF &pow_kappa_minus_one, const std::vector< FF > &degree_check_challenges) const
std::vector< std::string > labels_shplonk_batching_challenges
std::array< Commitment, NUM_WIRES > TableCommitments
static constexpr size_t NUM_WIRES
MergeSettings settings
An object storing two EC points that represent the inputs to a pairing check.
typename Group::element Element
Definition grumpkin.hpp:62
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:69
typename Group::affine_element AffineElement
Definition grumpkin.hpp:63
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
MergeSettings
The MergeSettings define whether an current subtable will be added at the beginning (PREPEND) or at t...
typename TranscriptFor< Curve >::type TranscriptFor_t
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:169
Result of merge verification.