Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
pairing_points.test.cpp
Go to the documentation of this file.
4
5#include <gtest/gtest.h>
6
7namespace bb {
8
9class NativePairingPointsTests : public ::testing::Test {
10 public:
14
16
17 // P0 = [s]₁, P1 = -[1]₁ satisfies e(P0,[1]₂)·e(P1,[s]₂) = 1
19 {
21 auto srs = ck.get_monomial_points();
22 return PP(srs[1], -srs[0]);
23 }
24};
25
26// Default construction produces infinity points
27TEST_F(NativePairingPointsTests, DefaultConstructionIsInfinity)
28{
29 PP pp;
30 EXPECT_EQ(pp.P0(), Point::infinity());
31 EXPECT_EQ(pp.P1(), Point::infinity());
32}
33
34// Infinity points pass the pairing check: e(∞, Q) = 1
35TEST_F(NativePairingPointsTests, InfinityPassesPairingCheck)
36{
37 PP pp;
38 EXPECT_TRUE(pp.check());
39}
40
41// Valid SRS-derived points pass the pairing check
42TEST_F(NativePairingPointsTests, ValidPointsPassPairingCheck)
43{
44 PP pp = make_valid_pairing_points();
45 EXPECT_TRUE(pp.check());
46}
47
48// Arbitrary non-trivial points fail the pairing check
49TEST_F(NativePairingPointsTests, InvalidPointsFailPairingCheck)
50{
51 Point G = Point::one();
52 PP pp(G, G);
53 EXPECT_FALSE(pp.check());
54}
55
56// Aggregating into default (infinity) adopts the incoming points
57TEST_F(NativePairingPointsTests, AggregateIntoDefaultAdoptsOther)
58{
59 PP acc;
60 PP other = make_valid_pairing_points();
61 acc.aggregate(other);
62 EXPECT_EQ(acc.P0(), other.P0());
63 EXPECT_EQ(acc.P1(), other.P1());
64}
65
66// Aggregating two populated sets produces a valid result
67TEST_F(NativePairingPointsTests, AggregatePopulatedPoints)
68{
69 PP acc = make_valid_pairing_points();
70 PP other = make_valid_pairing_points();
71 acc.aggregate(other);
72 EXPECT_TRUE(acc.check());
73}
74
75// Aggregating infinity into a populated accumulator throws
76TEST_F(NativePairingPointsTests, AggregateInfinityIntoPopulatedThrows)
77{
78 PP acc = make_valid_pairing_points();
79 PP empty;
80 EXPECT_THROW(acc.aggregate(empty), std::runtime_error);
81}
82
83} // namespace bb
CommitmentKey object over a pairing group 𝔾₁.
An object storing two EC points that represent the inputs to a pairing check.
typename Group::affine_element AffineElement
Definition bn254.hpp:22
#define G(r, i, a, b, c, d)
Definition blake2s.cpp:116
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
TEST_F(IPATest, ChallengesAreZero)
Definition ipa.test.cpp:155
CommitmentKey< Curve > ck