18static constexpr bb::fq DEFAULT_PAIRING_POINTS_P0_X(
19 "0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf");
20static constexpr bb::fq DEFAULT_PAIRING_POINTS_P0_Y(
21 "0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4");
22static constexpr bb::fq DEFAULT_PAIRING_POINTS_P1_X(
23 "0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38");
24static constexpr bb::fq DEFAULT_PAIRING_POINTS_P1_Y(
25 "0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f");
65 info(
"Are Pairing Points with tag ",
tag_index,
" valid? ", native_pp.
check() ?
"true" :
"false");
75 BB_ASSERT(idx < 2,
"Index out of bounds");
76 return idx == 0 ?
P0 :
P1;
81 BB_ASSERT(idx < 2,
"Index out of bounds");
82 return idx == 0 ?
P0 :
P1;
106 size_t num_points = pairing_points.size();
107 BB_ASSERT_GT(num_points, 1UL,
"This method should be used only with more than one pairing point.");
110 first_components.reserve(num_points);
112 second_components.reserve(num_points);
113 for (
const auto& points : pairing_points) {
114 first_components.emplace_back(points.P0);
115 second_components.emplace_back(points.P1);
120 std::vector<std::string> labels;
121 labels.reserve(num_points - 1);
122 for (
size_t idx = 0;
auto [first, second] :
zip_view(first_components, second_components)) {
124 transcript.add_to_hash_buffer(
"second_component_" +
std::to_string(idx), second);
127 labels.emplace_back(
"pp_aggregation_challenge_" +
std::to_string(idx));
132 std::vector<Fr> challenges = transcript.template get_challenges<Fr>(labels);
142 std::vector<Fr> scalars;
143 scalars.reserve(num_points);
144 scalars.push_back(
Fr(1));
145 scalars.insert(scalars.end(), challenges.begin(), challenges.end());
147 P0 = Group::batch_mul(first_components, scalars, 128, handle_edge_cases);
148 P1 = Group::batch_mul(second_components, scalars, 128, handle_edge_cases);
151 std::vector<Group> remaining_first(first_components.begin() + 1, first_components.end());
152 std::vector<Group> remaining_second(second_components.begin() + 1, second_components.end());
154 P0 = first_components[0];
155 P1 = second_components[0];
157 P0 += Group::batch_mul(remaining_first, challenges, 128, handle_edge_cases);
158 P1 += Group::batch_mul(remaining_second, challenges, 128, handle_edge_cases);
166 for (
const auto& points : pairing_points) {
167 builder->pairing_points_tagging.merge_pairing_point_tags(aggregated_points.
tag_index, points.tag_index);
171 return aggregated_points;
186 if (!this->has_data && other.
has_data) {
194 transcript.add_to_hash_buffer(
"Accumulator_P1",
P1);
195 transcript.add_to_hash_buffer(
"Aggregated_P0", other.
P0);
196 transcript.add_to_hash_buffer(
"Aggregated_P1", other.
P1);
197 auto recursion_separator =
198 transcript.template get_challenge<typename Curve::ScalarField>(
"recursion_separator");
202 P0 = Group::batch_mul({
P0, other.
P0 }, { 1, recursion_separator });
203 P1 = Group::batch_mul({
P1, other.
P1 }, { 1, recursion_separator });
206 Group point_to_aggregate = other.
P0.scalar_mul(recursion_separator, 128);
207 P0 += point_to_aggregate;
208 point_to_aggregate = other.
P1.scalar_mul(recursion_separator, 128);
209 P1 += point_to_aggregate;
215 builder->pairing_points_tagging.merge_pairing_point_tags(this->tag_index, other.
tag_index);
220 info(
"Are aggregated Pairing Points with tag ",
tag_index,
" valid? ", native_pp.
check() ?
"true" :
"false");
231 BB_ASSERT(this->has_data,
"Calling set_public on empty pairing points.");
232 uint32_t start_idx =
P0.set_public();
245 uint32_t start_idx = 0;
246 for (
size_t idx = 0;
auto const& coordinate : { DEFAULT_PAIRING_POINTS_P0_X,
247 DEFAULT_PAIRING_POINTS_P0_Y,
248 DEFAULT_PAIRING_POINTS_P1_X,
249 DEFAULT_PAIRING_POINTS_P1_Y }) {
253 start_idx = idx == 0 ?
index : start_idx;
268 const size_t FRS_PER_POINT = Group::PUBLIC_INPUTS_SIZE;
271 Group P0 = Group::reconstruct_from_public(P0_limbs);
272 Group P1 = Group::reconstruct_from_public(P1_limbs);
285 Fq x0(DEFAULT_PAIRING_POINTS_P0_X);
286 Fq y0(DEFAULT_PAIRING_POINTS_P0_Y);
287 Fq x1(DEFAULT_PAIRING_POINTS_P1_X);
288 Fq y1(DEFAULT_PAIRING_POINTS_P1_Y);
300 return os <<
"P0: " << as.
P0 <<
"\n"
301 <<
"P1: " << as.
P1 <<
"\n"
302 <<
"has_data: " << as.
has_data <<
"\n"
303 <<
"tag_index: " << as.
tag_index <<
"\n";
#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
void convert_constant_to_fixed_witness(Builder *builder)
uint32_t set_public() const
Set the witness indices of the binary basis limbs to public.
std::ostream & operator<<(std::ostream &os, PairingPoints< NCT > const &as)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
An object storing two EC points that represent the inputs to a pairing check.
typename Curve::Builder Builder
static constexpr size_t PUBLIC_INPUTS_SIZE
Curve::bool_ct operator==(PairingPoints const &other) 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 limbs of the pairing points to public.
Group & operator[](size_t idx)
static PairingPoints< Curve > reconstruct_from_public(const std::span< const Fr, PUBLIC_INPUTS_SIZE > &limbs)
Reconstruct an PairingPoints from its representation as limbs (generally stored in the public inputs)
static PairingPoints construct_default()
Construct default pairing points.
PairingPoints(std::array< Group, 2 > const &points)
const Group & operator[](size_t idx) const
PairingPoints(const Group &P0, const Group &P1)