Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
batch_merge_verifier.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
16
17namespace bb {
18
26template <typename Curve, size_t MaxMergeSize> class BatchMergeVerifier_ {
27 public:
28 using FF = typename Curve::ScalarField;
33 using Proof = std::vector<FF>;
36
38 static constexpr size_t MAX_MERGE_SIZE = MaxMergeSize;
39 static constexpr size_t LOG_MAX_MERGE_SIZE = static_cast<size_t>(numeric::get_msb(MAX_MERGE_SIZE));
40 static constexpr bool IsRecursive = Curve::is_stdlib_type;
41 static constexpr size_t NUM_COLUMN_TABLES = MAX_MERGE_SIZE + 1; // ZK table + subtables
43 static constexpr size_t NUM_EVALS =
44 ((MAX_MERGE_SIZE + 2) * NUM_WIRES) + 1; // ZK table, subtables, merged tables, degree check poly
45 static constexpr size_t NUM_OPENING_CLAIMS = NUM_EVALS;
46 static constexpr size_t MERGE_BATCHED_CLAIM_SIZE = NUM_OPENING_CLAIMS + 2; // Add Shplonk quotient + identity
47
48 using TableCommitments = std::array<Commitment, NUM_WIRES>;
49
58
59 // Public for testing purposes
60 std::shared_ptr<Transcript> transcript;
61
63 : transcript(std::make_shared<Transcript>())
64 {}
65
74 [[nodiscard("Verification result should be checked")]] ReductionResult reduce_to_pairing_check(const Proof& proof,
75 const FF hash);
76
81 static FF ecc_op_hash_step(const std::vector<Commitment>& col_commitments,
82 const std::optional<FF>& prev_hash = std::nullopt);
83
84 private:
91 std::vector<FF> compute_indicator_array(const FF& N) const;
92
99 std::vector<FF> compute_dirac_array(const std::vector<FF>& indicator_array) const;
100
108 bool check_concatenation_identity(std::vector<FF>& evals, const std::vector<FF>& pow_kappa_subtable_size) const;
109
115 bool check_degree_identity(std::vector<FF>& evals,
116 const std::vector<FF>& powers_of_kappa_inv,
117 const FF& kappa,
118 const std::vector<FF>& degree_check_challenges) const;
119
125 bool check_hash_consistency(const FF& hash,
126 const std::vector<FF>& calculated_hashes,
127 const std::vector<FF>& indicator_array) const;
128};
129
130// Type aliases for convenience
132
133namespace stdlib::recursion::goblin {
134template <typename Builder>
136} // namespace stdlib::recursion::goblin
137
138} // namespace bb
Unified batch verifier for the batch Goblin ECC op queue merge protocol.
static constexpr size_t MERGE_BATCHED_CLAIM_SIZE
std::shared_ptr< Transcript > transcript
bool check_degree_identity(std::vector< FF > &evals, const std::vector< FF > &powers_of_kappa_inv, const FF &kappa, const std::vector< FF > &degree_check_challenges) const
Verify the degree identity G(κ⁻¹) = Σ_{i,col} α_{i,col} · C_i_col(κ) · κ^{1 − shift_sizes[j]}.
typename Curve::ScalarField FF
ReductionResult reduce_to_pairing_check(const Proof &proof, const FF hash)
Reduce the batch merge proof to a pairing check.
bool check_concatenation_identity(std::vector< FF > &evals, const std::vector< FF > &pow_kappa_subtable_size) const
Verify the concatenation identity T(κ) = Σ_i C_i(κ) · κ^{offset_i} for every column.
static constexpr bool IsRecursive
static constexpr size_t NUM_WIRES
static FF ecc_op_hash_step(const std::vector< Commitment > &col_commitments, const std::optional< FF > &prev_hash=std::nullopt)
Compute one step of the ECC op running hash.
static constexpr size_t NUM_COLUMN_TABLES
typename Curve::AffineElement Commitment
std::vector< FF > compute_indicator_array(const FF &N) const
Compute array of length M := MaxMergeSize s.t. indicator_array[i] = (i < N).
static constexpr size_t NUM_EVALS
std::array< Commitment, NUM_WIRES > TableCommitments
static constexpr size_t LOG_MAX_MERGE_SIZE
static constexpr size_t NUM_EVALS_FROM_COLUMNS
std::conditional_t< Curve::is_stdlib_type, stdlib::recursion::PairingPoints< Curve >, bb::PairingPoints< Curve > > PairingPoints
std::vector< FF > compute_dirac_array(const std::vector< FF > &indicator_array) const
Compute array of length M := MaxMergeSize s.t. dirac_array[i] = (i == N - 1)
TranscriptFor_t< Curve > Transcript
static constexpr size_t MAX_MERGE_SIZE
bool check_hash_consistency(const FF &hash, const std::vector< FF > &calculated_hashes, const std::vector< FF > &indicator_array) const
Verify that the column commitments in the proof match the running hash from accumulation.
static constexpr size_t NUM_OPENING_CLAIMS
An object storing two EC points that represent the inputs to a pairing check.
Shplonk Verifier.
Definition shplonk.hpp:331
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:67
typename Group::affine_element AffineElement
Definition grumpkin.hpp:64
constexpr T get_msb(const T in)
Definition get_msb.hpp:50
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
typename TranscriptFor< Curve >::type TranscriptFor_t
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Result of batch merge verification.