Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
verifier_instance.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
12
13namespace bb {
19template <IsUltraOrMegaHonk Flavor_> class VerifierInstance_ {
20 public:
21 using Flavor = Flavor_;
22 using FF = typename Flavor::FF;
26 using WitnessCommitments = typename Flavor::WitnessCommitments;
28 using SubrelationSeparator = typename Flavor::SubrelationSeparator;
30
31 std::shared_ptr<VerificationKey> vk;
32
33 bool is_complete = false; // whether this instance has been completely populated
34 std::vector<FF> public_inputs; // to be extracted from the corresponding proof
35
36 SubrelationSeparator alpha; // a challenge whose powers are used to batch subrelation contributions during Sumcheck
38 std::vector<FF> gate_challenges;
39
42
43 // For ZK flavors: store Gemini masking polynomial commitment
45
46 VerifierInstance_() = default;
47 VerifierInstance_(std::shared_ptr<VerificationKey> vk)
48 : vk(vk)
49 {}
50
55 std::shared_ptr<VerificationKey> get_vk() const { return vk; }
56
66 FF hash_with_origin_tagging([[maybe_unused]] const std::string& domain_separator, Transcript& transcript) const
67 {
68 BB_ASSERT_EQ(is_complete, true, "Trying to hash a verifier instance that has not been completed.");
69
70 using Codec = typename Transcript::Codec;
71 std::vector<FF> instance_elements;
72
73 const OriginTag tag = bb::extract_transcript_tag(transcript);
74
75 // Tag, serialize, and append to instance_elements
76 auto append_tagged = [&]<typename T>(const T& component) {
77 auto frs = bb::tag_and_serialize<Transcript::in_circuit, Codec>(component, tag);
78 instance_elements.insert(instance_elements.end(), frs.begin(), frs.end());
79 };
80
81 // Tag and serialize VK metadata
82 append_tagged(this->vk->log_circuit_size);
83 append_tagged(this->vk->num_public_inputs);
84 append_tagged(this->vk->pub_inputs_offset);
85
86 // Tag and serialize VK precomputed commitments
87 for (const Commitment& commitment : this->vk->get_all()) {
88 append_tagged(commitment);
89 }
90
91 // Tag and serialize witness commitments
92 for (const Commitment& comm : witness_commitments.get_all()) {
93 append_tagged(comm);
94 }
95
96 // Tag and serialize challenges and parameters
97 append_tagged(this->alpha);
98 append_tagged(this->relation_parameters.eta);
99 append_tagged(this->relation_parameters.eta_two);
100 append_tagged(this->relation_parameters.eta_three);
101 append_tagged(this->relation_parameters.beta);
102 append_tagged(this->relation_parameters.gamma);
103 append_tagged(this->relation_parameters.public_input_delta);
104 append_tagged(this->gate_challenges);
105
106 // Sanitize free witness tags before hashing
107 bb::unset_free_witness_tags<Transcript::in_circuit, FF>(instance_elements);
108
109 // Hash the tagged elements directly
110 return Transcript::HashFunction::hash(instance_elements);
111 }
112
115};
116
117} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:77
A container for commitment labels.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
bb::VerifierCommitmentKey< Curve > VerifierCommitmentKey
typename Curve::ScalarField FF
typename G1::affine_element Commitment
NativeTranscript Transcript
The VerifierInstance encapsulates all the necessary information for a Mega Honk Verifier to verify a ...
typename Flavor::WitnessCommitments WitnessCommitments
VerifierInstance_()=default
FF hash_with_origin_tagging(const std::string &domain_separator, Transcript &transcript) const
Tag all components and hash.
std::vector< FF > public_inputs
std::vector< FF > gate_challenges
typename Flavor::FF FF
typename Flavor::CommitmentLabels CommitmentLabels
WitnessCommitments witness_commitments
MSGPACK_FIELDS(vk, relation_parameters, alpha, is_complete, gate_challenges, witness_commitments, gemini_masking_commitment)
std::shared_ptr< VerificationKey > get_vk() const
Get the verification key.
VerifierInstance_(std::shared_ptr< VerificationKey > vk)
typename Flavor::Transcript Transcript
std::shared_ptr< VerificationKey > vk
CommitmentLabels commitment_labels
typename Flavor::Commitment Commitment
typename Flavor::VerifierCommitmentKey VerifierCommitmentKey
SubrelationSeparator alpha
RelationParameters< FF > relation_parameters
typename Flavor::VerificationKey VerificationKey
typename Flavor::SubrelationSeparator SubrelationSeparator
Base class templates for structures that contain data parameterized by the fundamental polynomials of...
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
OriginTag extract_transcript_tag(const TranscriptType &transcript)
Extract origin tag context from a transcript.
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
Container for parameters used by the grand product (permutation, lookup) Honk relations.