Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
verifier_commitments.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Completed, auditors: [Sergei], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
10
11#include <memory>
12#include <type_traits>
13
14namespace bb {
15
16template <typename Flavor, typename Commitment, typename = void> struct VerifierCommitmentEntities {
17 using Type = typename Flavor::template AllEntities<Commitment>;
18};
19
20template <typename Flavor, typename Commitment>
21struct VerifierCommitmentEntities<Flavor, Commitment, std::void_t<typename Flavor::NativeFlavor>> {
22 using Type = typename Flavor::NativeFlavor::template AllEntities<Commitment>;
23};
24
25template <typename Flavor> class VerifierCommitmentsConstructor {
26 public:
29 using WitnessCommitments = typename Flavor::WitnessCommitments;
31
32 static Commitments construct(const std::shared_ptr<VerificationKey>& verification_key)
33 {
34 Commitments commitments;
35 copy_precomputed(commitments, verification_key);
36 return commitments;
37 }
38
39 static Commitments construct(const std::shared_ptr<VerificationKey>& verification_key,
40 const WitnessCommitments& witness_commitments)
41 {
42 Commitments commitments = construct(verification_key);
43 copy_witness(commitments, witness_commitments);
44 return commitments;
45 }
46
47 static Commitments construct(const std::shared_ptr<VerificationKey>& verification_key,
48 const WitnessCommitments& witness_commitments,
49 const Commitment& gemini_masking_commitment)
50 {
51 Commitments commitments = construct(verification_key, witness_commitments);
52 if constexpr (has_gemini_masking()) {
53 commitments.gemini_masking_poly() = gemini_masking_commitment;
54 }
55 return commitments;
56 }
57
58 private:
59 static constexpr bool has_gemini_masking()
60 {
61 if constexpr (requires { Flavor::HasGeminiMasking; }) {
62 return Flavor::HasGeminiMasking;
63 } else {
64 return Flavor::HasZK;
65 }
66 }
67
68 static void copy_precomputed(Commitments& commitments, const std::shared_ptr<VerificationKey>& verification_key)
69 {
70 for (auto [precomputed, in] : zip_view(commitments.get_precomputed(), verification_key->get_all())) {
71 precomputed = in;
72 }
73 }
74
75 static void copy_witness(Commitments& commitments, const WitnessCommitments& witness_commitments)
76 {
77 for (auto [witness, in] : zip_view(commitments.get_witness(), witness_commitments.get_all())) {
78 witness = in;
79 }
80 for (auto [shifted, src] : zip_view(commitments.get_shifted(), witness_commitments.get_to_be_shifted())) {
81 shifted = src;
82 }
83 }
84};
85
86} // namespace bb
static constexpr bool HasZK
typename G1::affine_element Commitment
FixedVKAndHash_< PrecomputedEntities< Commitment >, BF, ECCVMHardcodedVKAndHash > VerificationKey
The verification key stores commitments to the precomputed polynomials used by the verifier.
typename Flavor::WitnessCommitments WitnessCommitments
typename Flavor::VerificationKey VerificationKey
typename VerifierCommitmentEntities< Flavor, Commitment >::Type Commitments
static void copy_witness(Commitments &commitments, const WitnessCommitments &witness_commitments)
typename Flavor::Commitment Commitment
static void copy_precomputed(Commitments &commitments, const std::shared_ptr< VerificationKey > &verification_key)
static Commitments construct(const std::shared_ptr< VerificationKey > &verification_key)
static Commitments construct(const std::shared_ptr< VerificationKey > &verification_key, const WitnessCommitments &witness_commitments)
static Commitments construct(const std::shared_ptr< VerificationKey > &verification_key, const WitnessCommitments &witness_commitments, const Commitment &gemini_masking_commitment)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
STL namespace.
typename Flavor::template AllEntities< Commitment > Type