7#include <gtest/gtest.h>
21 static constexpr size_t NUM_GATES_ADDED = 20;
23 typename TypeParam::Builder
builder;
25 size_t num_gates =
builder.num_gates();
27 EXPECT_EQ(NUM_GATES_ADDED,
builder.num_gates() - num_gates)
28 <<
"There has been a change in the number of gates required to set default PairingPoints as public inputs.";
35 using Builder = TypeParam::Builder;
41 Group P0(DEFAULT_PAIRING_POINTS_P0_X, DEFAULT_PAIRING_POINTS_P0_Y,
false);
42 Group P1(DEFAULT_PAIRING_POINTS_P1_X, DEFAULT_PAIRING_POINTS_P1_Y,
false);
43 P0.convert_constant_to_fixed_witness(&
builder);
44 P1.convert_constant_to_fixed_witness(&
builder);
52 EXPECT_TRUE(native_pp.
check()) <<
"Default PairingPoints are not valid pairing points.";
57 using Curve = TypeParam;
58 using Builder =
typename Curve::Builder;
62 using NativeFr =
typename Curve::ScalarFieldNative;
66 Fr scalar_one = Fr::from_witness(&
builder, NativeFr::random_element());
67 Fr scalar_two = Fr::from_witness(&
builder, NativeFr::random_element());
68 Group P0 = Group::batch_mul({ Group::one(&
builder) }, { scalar_one });
69 Group P1 = Group::batch_mul({ Group::one(&
builder) }, { scalar_two });
72 EXPECT_TRUE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
82 EXPECT_FALSE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
89 EXPECT_TRUE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
100 EXPECT_FALSE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
112 EXPECT_TRUE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
118 using Curve = TypeParam;
119 using Builder =
typename Curve::Builder;
123 using NativeFr =
typename Curve::ScalarFieldNative;
129 Fr scalar_one = Fr::from_witness(&
builder, NativeFr::random_element());
130 Fr scalar_two = Fr::from_witness(&
builder, NativeFr::random_element());
131 Group P0 = Group::batch_mul({ Group::one(&
builder) }, { scalar_one });
132 Group P1 = Group::batch_mul({ Group::one(&
builder) }, { scalar_two });
144 EXPECT_FALSE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
147 pp_one.aggregate(pp_two);
150 EXPECT_FALSE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
155 ::testing::HasSubstr(
156 "Pairing points must all be aggregated together. Either no pairing points should be created, or all "
157 "created pairing points must be aggregated into a single pairing point. Found 2 different pairing "
161 pp_one.aggregate(pp_three);
166 ::testing::HasSubstr(
167 "Pairing points must be set to public in the circuit before constructing the ProverInstance."));
179 using Curve = TypeParam;
180 using Builder =
typename Curve::Builder;
185 using NativeFr = Curve::ScalarFieldNative;
189 Fr scalar_one = Fr::from_witness(&
builder, NativeFr::random_element());
190 Fr scalar_two = Fr::from_witness(&
builder, NativeFr::random_element());
191 Group P0 = Group::batch_mul({ Group::one(&
builder) }, { scalar_one });
192 Group P1 = Group::batch_mul({ Group::one(&
builder) }, { scalar_two });
198 EXPECT_TRUE(
builder.pairing_points_tagging.has_single_pairing_point_tag());
#define BB_ASSERT_EQ(actual, expected,...)
#define EXPECT_THROW_OR_ABORT(statement, matcher)
CommitmentKey object over a pairing group 𝔾₁.
An object storing two EC points that represent the inputs to a pairing check.
bool check() const
Perform the pairing check.
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
static void SetUpTestSuite()
Manages the data that is propagated on the public inputs of an application/function circuit.
PairingInputs pairing_inputs
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
TYPED_TEST(PairingPointsTests, ConstructDefault)
TYPED_TEST_SUITE(PairingPointsTests, Curves)
testing::Types< stdlib::bn254< UltraCircuitBuilder >, stdlib::bn254< MegaCircuitBuilder > > Curves
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
An object storing two EC points that represent the inputs to a pairing check.
static uint32_t set_default_to_public(Builder *builder)
Set the witness indices for the default limbs of the pairing points to public.
void aggregate(PairingPoints const &other)
Compute a linear combination of the present pairing points with an input set of pairing points.
uint32_t set_public()
Set the witness indices for the limbs of the pairing points to public.
static PairingPoints aggregate_multiple(std::vector< PairingPoints > &pairing_points)
Aggregate multiple PairingPoints.