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: 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
8
13
14namespace bb {
15
26 using Point = typename Curve::AffineElement;
27 using Fr = typename Curve::ScalarField;
28 using Fq = typename Curve::BaseField;
30
31 public:
32 static constexpr size_t PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE;
33
34 Point P0 = Point::infinity();
35 Point P1 = Point::infinity();
36
37 PairingPoints() = default;
38 PairingPoints(const Point& P0, const Point& P1)
39 : P0(P0)
40 , P1(P1)
41 {}
42
48 {
49 const std::span<const bb::fr, Point::PUBLIC_INPUTS_SIZE> P0_limbs(limbs_in.data(), Point::PUBLIC_INPUTS_SIZE);
50 const std::span<const bb::fr, Point::PUBLIC_INPUTS_SIZE> P1_limbs(limbs_in.data() + Point::PUBLIC_INPUTS_SIZE,
51 Point::PUBLIC_INPUTS_SIZE);
52 Point P0 = Point::reconstruct_from_public(P0_limbs);
53 Point P1 = Point::reconstruct_from_public(P1_limbs);
54
55 return PairingPoints{ P0, P1 };
56 }
57
61 void aggregate(const PairingPoints& other)
62 {
63 if (P0 == Point::infinity() || P1 == Point::infinity() || other.P0 == Point::infinity() ||
64 other.P1 == Point::infinity()) {
65 throw_or_abort("WARNING: Shouldn't be aggregating with Point at infinity! The pairing points are probably "
66 "uninitialized.");
67 }
68 Fr aggregation_separator = Fr::random_element();
69 P0 = P0 + other.P0 * aggregation_separator;
70 P1 = P1 + other.P1 * aggregation_separator;
71 }
72
76 bool check() const
77 {
78 VerifierCK pcs_vkey{};
79 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1423): Rename to verifier_pcs_key or vckey or
80 // something. Issue exists in many places besides just here.
81 return pcs_vkey.pairing_check(P0, P1);
82 }
83
84 bool operator==(const PairingPoints& other) const = default;
85};
86
87} // namespace bb
CommitmentKey object over a pairing group 𝔾₁.
An object storing two bn254 points that represent the inputs to a pairing check.
static constexpr size_t PUBLIC_INPUTS_SIZE
bool check() const
Perform the pairing check.
bool operator==(const PairingPoints &other) const =default
PairingPoints()=default
typename Curve::BaseField Fq
typename Curve::ScalarField Fr
void aggregate(const PairingPoints &other)
Aggregate the current pairing points with another set of pairing points using a random scalar.
static PairingPoints reconstruct_from_public(const std::span< const Fr, PUBLIC_INPUTS_SIZE > &limbs_in)
Reconstruct the pairing points from limbs stored on the public inputs.
PairingPoints(const Point &P0, const Point &P1)
typename Curve::AffineElement Point
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.
bb::fq BaseField
Definition bn254.hpp:19
typename Group::affine_element AffineElement
Definition bn254.hpp:22
bb::fr ScalarField
Definition bn254.hpp:18
Entry point for Barretenberg command-line interface.
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)