21static constexpr bb::fr DEFAULT_PP_P0_X_LO =
22 bb::fr(
"0x000000000000000000000000000000b75c020998797da7842ab5d6d1986846cf");
23static constexpr bb::fr DEFAULT_PP_P0_X_HI =
24 bb::fr(
"0x0000000000000000000000000000000000031e97a575e9d05a107acb64952eca");
25static constexpr bb::fr DEFAULT_PP_P0_Y_LO =
26 bb::fr(
"0x000000000000000000000000000000c410db10a01750aebb5666547acf8bd5a4");
27static constexpr bb::fr DEFAULT_PP_P0_Y_HI =
28 bb::fr(
"0x0000000000000000000000000000000000178cbf4206471d722669117f9758a4");
29static constexpr bb::fr DEFAULT_PP_P1_X_LO =
30 bb::fr(
"0x0000000000000000000000000000007fd51009034b3357f0e91b8a11e7842c38");
31static constexpr bb::fr DEFAULT_PP_P1_X_HI =
32 bb::fr(
"0x00000000000000000000000000000000000f94656a2ca489889939f81e9c7402");
33static constexpr bb::fr DEFAULT_PP_P1_Y_LO =
34 bb::fr(
"0x00000000000000000000000000000093fe27776f50224bd6fb128b46c1ddb67f");
35static constexpr bb::fr DEFAULT_PP_P1_Y_HI =
36 bb::fr(
"0x00000000000000000000000000000000001b52c2020d7464a0c80c0da527a081");
41static constexpr bb::fq DEFAULT_PAIRING_POINT_P0_X =
43static constexpr bb::fq DEFAULT_PAIRING_POINT_P0_Y =
45static constexpr bb::fq DEFAULT_PAIRING_POINT_P1_X =
47static constexpr bb::fq DEFAULT_PAIRING_POINT_P1_Y =
69 static constexpr size_t SIZE = 2;
94 info(
"Are Pairing Points with tag ",
tag_index,
" valid? ", native_pp.
check() ?
"true" :
"false");
116 return P0() == other.
P0() &&
P1() == other.
P1();
138 size_t num_points = pairing_points.size();
139 BB_ASSERT_GT(num_points, 1UL,
"This method should be used only with more than one pairing point.");
142 first_components.reserve(num_points);
144 second_components.reserve(num_points);
145 for (
const auto& points : pairing_points) {
146 first_components.emplace_back(points.P0());
147 second_components.emplace_back(points.P1());
152 std::vector<std::string> labels;
153 labels.reserve(num_points - 1);
154 for (
size_t idx = 0;
auto [first, second] :
zip_view(first_components, second_components)) {
156 transcript.add_to_hash_buffer(
"second_component_" +
std::to_string(idx), second);
159 labels.emplace_back(
"pp_aggregation_challenge_" +
std::to_string(idx));
164 std::vector<Fr> challenges = transcript.template get_challenges<Fr>(labels);
174 std::vector<Fr> scalars;
175 scalars.reserve(num_points);
176 scalars.push_back(
Fr(1));
177 scalars.insert(scalars.end(), challenges.begin(), challenges.end());
179 P0 = Group::batch_mul(first_components, scalars, 128, handle_edge_cases);
180 P1 = Group::batch_mul(second_components, scalars, 128, handle_edge_cases);
183 std::vector<Group> remaining_first(first_components.begin() + 1, first_components.end());
184 std::vector<Group> remaining_second(second_components.begin() + 1, second_components.end());
186 P0 = first_components[0];
187 P1 = second_components[0];
189 P0 += Group::batch_mul(remaining_first, challenges, 128, handle_edge_cases);
190 P1 += Group::batch_mul(remaining_second, challenges, 128, handle_edge_cases);
198 for (
const auto& points : pairing_points) {
199 builder->pairing_points_tagging.merge_pairing_point_tags(aggregated_points.
tag_index, points.tag_index);
203 return aggregated_points;
218 if (!this->has_data && other.
has_data) {
226 transcript.add_to_hash_buffer(
"Accumulator_P1",
P1());
227 transcript.add_to_hash_buffer(
"Aggregated_P0", other.
P0());
228 transcript.add_to_hash_buffer(
"Aggregated_P1", other.
P1());
229 auto recursion_separator =
230 transcript.template get_challenge<typename Curve::ScalarField>(
"recursion_separator");
234 P0() = Group::batch_mul({
P0(), other.
P0() }, { 1, recursion_separator });
235 P1() = Group::batch_mul({
P1(), other.
P1() }, { 1, recursion_separator });
238 Group point_to_aggregate = other.
P0().scalar_mul(recursion_separator, 128);
239 P0() += point_to_aggregate;
240 point_to_aggregate = other.
P1().scalar_mul(recursion_separator, 128);
241 P1() += point_to_aggregate;
247 builder->pairing_points_tagging.merge_pairing_point_tags(this->tag_index, other.
tag_index);
252 info(
"Are aggregated Pairing Points with tag ",
tag_index,
" valid? ", native_pp.
check() ?
"true" :
"false");
262 BB_ASSERT(this->has_data,
"Calling set_public on empty pairing points.");
263 uint32_t start_idx =
P0().set_public();
273 BB_ASSERT(this->has_data,
"Calling fix_witness on empty pairing points.");
284 BB_ASSERT(this->has_data,
"Calling check on empty pairing points.");
286 return native_pp.
check();
308 uint32_t start_idx = add_fixed_public(DEFAULT_PP_P0_X_LO);
309 add_fixed_public(DEFAULT_PP_P0_X_HI);
310 add_fixed_public(DEFAULT_PP_P0_Y_LO);
311 add_fixed_public(DEFAULT_PP_P0_Y_HI);
312 add_fixed_public(DEFAULT_PP_P1_X_LO);
313 add_fixed_public(DEFAULT_PP_P1_X_HI);
314 add_fixed_public(DEFAULT_PP_P1_Y_LO);
315 add_fixed_public(DEFAULT_PP_P1_Y_HI);
325 Fq P0_x(DEFAULT_PAIRING_POINT_P0_X);
326 Fq P0_y(DEFAULT_PAIRING_POINT_P0_Y);
327 Fq P1_x(DEFAULT_PAIRING_POINT_P1_X);
328 Fq P1_y(DEFAULT_PAIRING_POINT_P1_Y);
340 return os <<
"P0: " << as.
P0() <<
"\n"
341 <<
"P1: " << as.
P1() <<
"\n"
342 <<
"has_data: " << as.
has_data <<
"\n"
343 <<
"tag_index: " << as.
tag_index <<
"\n";
350template <
typename Curve>
351struct tuple_size<
bb::stdlib::recursion::PairingPoints<Curve>> : std::integral_constant<size_t, 2> {};
#define BB_ASSERT(expression,...)
#define BB_ASSERT_GT(left, right,...)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
void add_to_hash_buffer(const std::string &label, const T &element)
Adds an element to the transcript.
An object storing two EC points that represent the inputs to a pairing check.
bool check() const
Perform the pairing check.
typename grumpkin::g1 Group
std::ostream & operator<<(std::ostream &os, PairingPoints< NCT > const &as)
Entry point for Barretenberg command-line interface.
field< Bn254FqParams > fq
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
StdlibCodec for in-circuit (recursive) verification transcript handling.
An object storing two EC points that represent the inputs to a pairing check.
static constexpr size_t size()
typename Curve::Builder Builder
static constexpr size_t PUBLIC_INPUTS_SIZE
Curve::bool_ct operator==(PairingPoints const &other) const
bool check() const
Perform native pairing check on the witness values.
const auto & operator[](size_t idx) const
static uint32_t set_default_to_public(Builder *builder)
Set the witness indices for the default limbs of the pairing points to public.
static PairingPoints aggregate_multiple(std::vector< PairingPoints > &pairing_points, bool handle_edge_cases=true)
Aggregate multiple PairingPoints using random linear combination.
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 pairing points to public.
std::array< Group, 2 > _points
static PairingPoints construct_default()
Construct default pairing points.
static constexpr size_t SIZE
auto & operator[](size_t idx)
void fix_witness()
Record the witness values of pairing points' coordinates in the selectors.
PairingPoints(const Group &p0, const Group &p1)