16static constexpr bb::fq DEFAULT_PAIRING_POINTS_P0_X(
17 "0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf");
18static constexpr bb::fq DEFAULT_PAIRING_POINTS_P0_Y(
19 "0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4");
20static constexpr bb::fq DEFAULT_PAIRING_POINTS_P1_X(
21 "0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38");
22static constexpr bb::fq DEFAULT_PAIRING_POINTS_P1_Y(
23 "0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f");
63 info(
"Are Pairing Points with tag ",
tag_index,
" valid? ", native_pp.
check() ?
"true" :
"false");
73 BB_ASSERT(idx < 2,
"Index out of bounds");
74 return idx == 0 ?
P0 :
P1;
79 BB_ASSERT(idx < 2,
"Index out of bounds");
80 return idx == 0 ?
P0 :
P1;
93 size_t num_points = pairing_points.size();
94 BB_ASSERT_GT(num_points, 1UL,
"This method should be used only with more than one pairing point.");
97 first_components.reserve(num_points);
99 second_components.reserve(num_points);
100 for (
const auto& points : pairing_points) {
101 first_components.emplace_back(points.P0);
102 second_components.emplace_back(points.P1);
107 std::vector<std::string> labels;
108 labels.reserve(num_points);
109 for (
size_t idx = 0;
auto [first, second] :
zip_view(first_components, second_components)) {
111 transcript.add_to_hash_buffer(
"second_component_" +
std::to_string(idx), second);
112 labels.emplace_back(
"pp_aggregation_challenge_" +
std::to_string(idx));
116 std::vector<Fr> challenges = transcript.template get_challenges<Fr>(labels);
119 auto P0 = Group::batch_mul(first_components, challenges);
120 auto P1 = Group::batch_mul(second_components, challenges);
127 for (
const auto& points : pairing_points) {
128 builder->pairing_points_tagging.merge_pairing_point_tags(aggregated_points.
tag_index, points.tag_index);
132 return aggregated_points;
147 if (!this->has_data && other.
has_data) {
155 transcript.add_to_hash_buffer(
"Accumulator_P1",
P1);
156 transcript.add_to_hash_buffer(
"Aggregated_P0", other.
P0);
157 transcript.add_to_hash_buffer(
"Aggregated_P1", other.
P1);
158 auto recursion_separator =
159 transcript.template get_challenge<typename Curve::ScalarField>(
"recursion_separator");
163 P0 = Group::batch_mul({
P0, other.
P0 }, { 1, recursion_separator });
164 P1 = Group::batch_mul({
P1, other.
P1 }, { 1, recursion_separator });
167 Group point_to_aggregate = other.
P0.scalar_mul(recursion_separator, 128);
168 P0 += point_to_aggregate;
169 point_to_aggregate = other.
P1.scalar_mul(recursion_separator, 128);
170 P1 += point_to_aggregate;
176 builder->pairing_points_tagging.merge_pairing_point_tags(this->tag_index, other.
tag_index);
181 info(
"Aggregated Pairing Points with tag ",
tag_index,
": valid: ", native_pp.
check() ?
"true" :
"false");
192 BB_ASSERT(this->has_data,
"Calling set_public on empty pairing points.");
193 uint32_t start_idx =
P0.set_public();
206 uint32_t start_idx = 0;
207 for (
size_t idx = 0;
auto const& coordinate : { DEFAULT_PAIRING_POINTS_P0_X,
208 DEFAULT_PAIRING_POINTS_P0_Y,
209 DEFAULT_PAIRING_POINTS_P1_X,
210 DEFAULT_PAIRING_POINTS_P1_Y }) {
214 start_idx = idx == 0 ?
index : start_idx;
229 const size_t FRS_PER_POINT = Group::PUBLIC_INPUTS_SIZE;
232 Group P0 = Group::reconstruct_from_public(P0_limbs);
233 Group P1 = Group::reconstruct_from_public(P1_limbs);
246 Fq x0(DEFAULT_PAIRING_POINTS_P0_X);
247 Fq y0(DEFAULT_PAIRING_POINTS_P0_Y);
248 Fq x1(DEFAULT_PAIRING_POINTS_P1_X);
249 Fq y1(DEFAULT_PAIRING_POINTS_P1_Y);
261 return os <<
"P0: " << as.
P0 <<
"\n"
262 <<
"P1: " << as.
P1 <<
"\n"
263 <<
"has_data: " << as.
has_data <<
"\n"
264 <<
"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.
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 aggregate_multiple(std::vector< PairingPoints > &pairing_points)
Aggregate multiple PairingPoints.
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)