Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
pairing_points.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Planned, auditors: [Khashayar], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
12
13namespace bb {
14
22template <typename Curve_> class PairingPoints {
23 public:
24 using Curve = Curve_;
26 using Point = typename Curve::AffineElement;
27 using Fr = typename Curve::ScalarField;
28 using Fq = typename Curve::BaseField;
30
31 static constexpr size_t PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE;
32
33 // Array-like interface for Codec compatibility
35 static constexpr size_t SIZE = 2;
36
37 std::array<Point, 2> _points = { Point::infinity(), Point::infinity() };
38
39 // Named accessors
40 Point& P0() { return _points[0]; }
41 Point& P1() { return _points[1]; }
42 const Point& P0() const { return _points[0]; }
43 const Point& P1() const { return _points[1]; }
44
45 PairingPoints() = default;
46 PairingPoints(const Point& p0, const Point& p1)
47 : _points{ p0, p1 }
48 {}
49
50 auto& operator[](size_t idx) { return _points[idx]; }
51 const auto& operator[](size_t idx) const { return _points[idx]; }
52
53 // Iterator support for range-based for (required by Codec)
54 auto begin() { return _points.begin(); }
55 auto end() { return _points.end(); }
56 auto begin() const { return _points.begin(); }
57 auto end() const { return _points.end(); }
58 static constexpr size_t size() { return SIZE; }
59
64 {
65 if (P0() == Point::infinity() || P1() == Point::infinity() || other.P0() == Point::infinity() ||
66 other.P1() == Point::infinity()) {
67 throw_or_abort("WARNING: Shouldn't be aggregating with Point at infinity! The pairing points are probably "
68 "uninitialized.");
69 }
70 Fr aggregation_separator = Fr::random_element();
71 P0() = P0() + other.P0() * aggregation_separator;
72 P1() = P1() + other.P1() * aggregation_separator;
73 }
74
78 bool check() const
79 {
80 VerifierCK pcs_vkey{};
81 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1423): Rename to verifier_pcs_key or vckey or
82 // something. Issue exists in many places besides just here.
83 return pcs_vkey.pairing_check(P0(), P1());
84 }
85
86 bool operator==(const PairingPoints<Curve>& other) const = default;
87};
88
89} // namespace bb
90
91// Enable std::tuple_size for Codec compatibility (array-like deserialization)
92namespace std {
93template <typename Curve> struct tuple_size<bb::PairingPoints<Curve>> : std::integral_constant<size_t, 2> {};
94} // namespace std
CommitmentKey object over a pairing group 𝔾₁.
An object storing two EC points that represent the inputs to a pairing check.
void aggregate(const PairingPoints< Curve > &other)
Aggregate the current pairing points with another set of pairing points using a random scalar.
static constexpr size_t size()
std::array< Point, 2 > _points
const Point & P1() const
bool operator==(const PairingPoints< Curve > &other) const =default
static constexpr size_t PUBLIC_INPUTS_SIZE
static constexpr size_t SIZE
PairingPoints(const Point &p0, const Point &p1)
bool check() const
Perform the pairing check.
typename Curve::BaseField Fq
const auto & operator[](size_t idx) const
typename Curve::AffineElement Point
auto & operator[](size_t idx)
PairingPoints()=default
const Point & P0() const
typename Curve::ScalarField Fr
bool pairing_check(const GroupElement &p0, const GroupElement &p1)
verifies a pairing equation over 2 points using the verifier SRS
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::affine_element AffineElement
Definition grumpkin.hpp:63
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static field random_element(numeric::RNG *engine=nullptr) noexcept
void throw_or_abort(std::string const &err)