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
18
19#include <memory>
20
21namespace bb {
22
23template <class Curve> class VerifierCommitmentKey;
24
30template <> class VerifierCommitmentKey<curve::BN254> {
31 public:
33 using GroupElement = typename Curve::Element;
35
37
39 {
40 if (!srs) {
41 srs = srs::get_crs_factory<Curve>()->get_verifier_crs();
42 }
43 };
44
45 bool initialized() const { return srs != nullptr; }
46
48 {
49 initialize();
50 return srs->get_g1_identity();
51 }
52
56 bool pairing_check(const GroupElement& p0, const GroupElement& p1)
57 {
58 initialize();
59 std::array<Commitment, 2> pairing_points{ p0, p1 };
61 pairing_points.data(), srs->get_precomputed_g2_lines(), 2);
62
63 return (result == Curve::TargetField::one());
64 }
65
66 private:
68};
69
75template <> class VerifierCommitmentKey<curve::Grumpkin> {
76 public:
78 using GroupElement = typename Curve::Element;
80
87 VerifierCommitmentKey(size_t num_points, const std::shared_ptr<bb::srs::factories::CrsFactory<Curve>>& crs_factory)
88 : srs(crs_factory->get_crs(num_points))
89 {}
90
91 VerifierCommitmentKey(size_t num_points) { srs = srs::get_crs_factory<Curve>()->get_crs(num_points); }
92
94
95 bool initialized() const { return srs != nullptr; }
96
97 Commitment get_g1_identity() const { return srs->get_g1_identity(); }
98
99 std::span<const Commitment> get_monomial_points() const { return srs->get_monomial_points(); }
100
101 private:
103};
104
105} // namespace bb
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:64
typename Group::affine_element AffineElement
Definition grumpkin.hpp:65
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