Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
batched_honk_translator_verifier.hpp
Go to the documentation of this file.
1#pragma once
2
13
14namespace bb {
15
32template <typename Curve> class BatchedHonkTranslatorVerifier_ {
33 public:
34 static constexpr bool IsRecursive = Curve::is_stdlib_type;
35
36 // Select MegaZK flavor based on native vs recursive.
38 // Select translator flavor based on native vs recursive.
40
41 using FF = typename MegaZKFlavorT::FF;
42 using Commitment = typename MegaZKFlavorT::Commitment;
44 using MegaZKVKAndHash = typename MegaZKFlavorT::VKAndHash;
46 using MegaZKVerifierCommitments = typename MegaZKFlavorT::VerifierCommitments;
47 using TransVerifierCommitments = typename TransFlavor::VerifierCommitments;
48
49 // Proof type: stdlib::Proof<UltraCircuitBuilder> for recursive, HonkProof for native.
51
52 // PairingPoints type.
55
56 // BF type from the translator flavor (BN254 base field elements).
57 using TransBF = typename TransFlavor::BF;
58
59 // Joint RepeatedCommitmentsData for Shplemini's remove_repeated_commitments optimization.
60 // After Shplemini's offset=2 (Q_commitment + gemini_masking_poly), the virtual layout is:
61 // Unshifted: [MegaZK_precomputed(P) | MegaZK_witness(W) | Trans_PCS_unshifted(TU)]
62 // Shifted: [MegaZK_shifted(S) | Trans_PCS_shifted(TS)]
63 //
64 // Range 1 (MegaZK): witness[0..S-1] ↔ mega_zk_shifted[0..S-1]
65 // Range 2 (Translator merged): ordered(5)+z_perm(1)+concat(5) in unshifted ↔ same in shifted
67 constexpr size_t P = MegaZKFlavorT::NUM_PRECOMPUTED_ENTITIES;
68 // W = MegaFlavor::NUM_WITNESS_ENTITIES (without masking, which is handled by Shplemini's offset)
69 constexpr size_t W = MegaZKFlavorT::REPEATED_COMMITMENTS.first.duplicate_start -
70 MegaZKFlavorT::REPEATED_COMMITMENTS.first.original_start;
71 constexpr size_t S = MegaZKFlavorT::NUM_SHIFTED_ENTITIES;
72 constexpr size_t TU = TranslatorFlavor::NUM_PCS_UNSHIFTED;
73 // Skip before repeated entries: masking(1)+ordered_extra(1)+op(1)=3 in unshifted, op_queue(3) in shifted
74 constexpr size_t TRANS_UNSHIFTED_SKIP = TranslatorFlavor::REPEATED_COMMITMENTS.first.original_start + 1;
75 constexpr size_t TRANS_SHIFTED_SKIP =
79 P, // MegaZK original: start of witness in unshifted
80 P + W + TU, // MegaZK duplicate: start of mega_zk_shifted
81 S, // MegaZK count
82 P + W + TRANS_UNSHIFTED_SKIP, // Translator original: ordered+z_perm+concat in unshifted
83 P + W + TU + S + TRANS_SHIFTED_SKIP, // Translator duplicate: same entries in shifted
86 }();
87
95
100 struct OinkResult {
101 std::vector<FF> public_inputs;
103 std::array<Commitment, MegaZKFlavorT::NUM_WIRES> ecc_op_wires;
104 };
105
111 BatchedHonkTranslatorVerifier_(std::shared_ptr<MegaZKVKAndHash> mega_zk_vk_and_hash,
112 std::shared_ptr<Transcript> transcript);
113
119 OinkResult verify_mega_zk_oink(const Proof& mega_zk_proof);
120
127 [[nodiscard("Verification result should be checked")]] ReductionResult verify(
128 const Proof& joint_proof,
129 const TransBF& evaluation_input_x,
130 const TransBF& batching_challenge_v,
131 const TransBF& accumulated_result,
132 const std::array<Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES>& op_queue_wire_commitments);
133
134 private:
135 // Methods mirroring the prover's structure.
137 const Proof& joint_proof,
138 const TransBF& evaluation_input_x,
139 const TransBF& batching_challenge_v,
140 const TransBF& accumulated_result,
141 const std::array<Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES>& op_queue_wire_commitments);
143 ReductionResult verify_joint_pcs(bool sumcheck_verified,
144 MegaZKVerifierCommitments& mega_zk_commitments,
145 TransVerifierCommitments& trans_commitments);
146
147 std::shared_ptr<MegaZKVKAndHash> mega_zk_vk_and_hash;
148 std::shared_ptr<Transcript> transcript;
149
150 // Verifier instance stored after verify_mega_zk_oink (provides accessors)
152
153 // Builder pointer (only meaningful for recursive, nullptr for native).
155
156 // Relation parameters populated during verify_mega_zk_oink / verify_translator_oink.
159
160 // State populated by verify_joint_sumcheck(), consumed by verify_joint_pcs().
161 std::vector<FF> joint_challenge;
162 typename MegaZKFlavorT::AllValues mega_zk_evals;
163 typename TransFlavor::AllValues trans_evals;
164 std::array<Commitment, NUM_LIBRA_COMMITMENTS> libra_commitments;
167};
168
169// Type aliases.
172
173} // namespace bb
Verifier for the batched MegaZK circuit + translator sumcheck and PCS.
std::array< Commitment, NUM_LIBRA_COMMITMENTS > libra_commitments
std::conditional_t< IsRecursive, stdlib::Proof< UltraCircuitBuilder >, HonkProof > Proof
std::shared_ptr< MegaZKVerifierInstance > mega_zk_verifier_instance
typename TransFlavor::VerifierCommitments TransVerifierCommitments
std::conditional_t< IsRecursive, MegaZKRecursiveFlavor_< UltraCircuitBuilder >, MegaZKFlavor > MegaZKFlavorT
ReductionResult verify_joint_pcs(bool sumcheck_verified, MegaZKVerifierCommitments &mega_zk_commitments, TransVerifierCommitments &trans_commitments)
Execute the joint Shplemini / KZG PCS reduction.
ReductionResult verify(const Proof &joint_proof, const TransBF &evaluation_input_x, const TransBF &batching_challenge_v, const TransBF &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
Phase 2: Verify translator Oink + joint sumcheck + joint PCS.
bool verify_joint_sumcheck()
Verify the joint 17-round sumcheck.
typename MegaZKFlavorT::VKAndHash MegaZKVKAndHash
std::shared_ptr< MegaZKVKAndHash > mega_zk_vk_and_hash
std::conditional_t< IsRecursive, UltraStdlibTranscript, NativeTranscript > Transcript
std::conditional_t< IsRecursive, TranslatorRecursiveFlavor, TranslatorFlavor > TransFlavor
TransVerifierCommitments verify_translator_oink(const Proof &joint_proof, const TransBF &evaluation_input_x, const TransBF &batching_challenge_v, const TransBF &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
Verify the translator's Oink phase.
std::conditional_t< IsRecursive, stdlib::recursion::PairingPoints< Curve >, bb::PairingPoints< Curve > > PairingPoints
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
std::conditional_t< IsRecursive, UltraCircuitBuilder *, std::nullptr_t > builder
OinkResult verify_mega_zk_oink(const Proof &mega_zk_proof)
Phase 1: Verify the MegaZK Oink phase on the shared transcript.
typename MegaZKFlavorT::VerifierCommitments MegaZKVerifierCommitments
Child class of MegaFlavor that runs with ZK Sumcheck.
An object storing two EC points that represent the inputs to a pairing check.
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS
static constexpr size_t NUM_PCS_UNSHIFTED
static constexpr size_t NUM_PCS_TO_BE_SHIFTED
The VerifierInstance encapsulates all the necessary information for a Honk Verifier to verify a proof...
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:68
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::vector< fr > HonkProof
Definition proof.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::array< Commitment, MegaZKFlavorT::NUM_WIRES > ecc_op_wires
Container for parameters used by the grand product (permutation, lookup) Honk relations.