Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
verification_key.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Luke], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
19
20#include <memory>
21
22namespace bb {
23
24template <class Curve> class VerifierCommitmentKey;
25
31template <> class VerifierCommitmentKey<curve::BN254> {
32 public:
34 using GroupElement = typename Curve::Element;
36
38
40 {
41 if (!srs) {
42 srs = srs::get_crs_factory<Curve>()->get_verifier_crs();
43 }
44 };
45
46 bool initialized() const { return srs != nullptr; }
47
49 {
50 initialize();
51 return srs->get_g1_identity();
52 }
53
57 bool pairing_check(const GroupElement& p0, const GroupElement& p1)
58 {
59 initialize();
60 std::array<Commitment, 2> pairing_points{ p0, p1 };
62 pairing_points.data(), srs->get_precomputed_g2_lines(), 2);
63
64 return (result == Curve::TargetField::one());
65 }
66
67 private:
69};
70
76template <> class VerifierCommitmentKey<curve::Grumpkin> {
77 public:
79 using GroupElement = typename Curve::Element;
81
88 VerifierCommitmentKey(size_t num_points, const std::shared_ptr<bb::srs::factories::CrsFactory<Curve>>& crs_factory)
89 : srs(crs_factory->get_crs(num_points))
90 {}
91
92 VerifierCommitmentKey(size_t num_points) { srs = srs::get_crs_factory<Curve>()->get_crs(num_points); }
93
95
96 bool initialized() const { return srs != nullptr; }
97
99 {
100 BB_ASSERT(srs != nullptr, "VerifierCommitmentKey<Grumpkin>: SRS not initialized (default-constructed key)");
101 return srs->get_g1_identity();
102 }
103
105 {
106 BB_ASSERT(srs != nullptr, "VerifierCommitmentKey<Grumpkin>: SRS not initialized (default-constructed key)");
107 return srs->get_monomial_points();
108 }
109
110 private:
112};
113
114} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:70
std::shared_ptr< bb::srs::factories::Crs< Curve > > srs
bool pairing_check(const GroupElement &p0, const GroupElement &p1)
Verify the pairing equation e(P₀,[1]₂) · e(P₁,[x]₂) = [1]ₜ
typename Curve::AffineElement Commitment
std::span< const Commitment > get_monomial_points() const
VerifierCommitmentKey(size_t num_points, const std::shared_ptr< bb::srs::factories::CrsFactory< Curve > > &crs_factory)
Construct a new IPA Verification Key object from existing SRS.
std::shared_ptr< bb::srs::factories::Crs< Curve > > srs
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
Definition grumpkin.hpp:63
typename Group::affine_element AffineElement
Definition grumpkin.hpp:64
fq12 reduced_ate_pairing_batch_precomputed(const g1::affine_element *P_affines, const miller_lines *lines, const size_t num_points)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
@ BN254
Definition types.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
VectorField result