18 constexpr size_t COMPRESSED_POINT_SIZE = 32;
21 size_t bytes_per_point = num_points > 0 ? points_buf.size() / num_points : 0;
23 std::vector<uint8_t> uncompressed_out;
25 if (bytes_per_point == UNCOMPRESSED_POINT_SIZE) {
28 for (
auto i : chunk.
range(
static_cast<size_t>(num_points))) {
29 g1_points[i] = from_buffer<g1::affine_element>(points_buf.data(), i * UNCOMPRESSED_POINT_SIZE);
32 }
else if (bytes_per_point == COMPRESSED_POINT_SIZE) {
35 for (
auto i : chunk.
range(
static_cast<size_t>(num_points))) {
36 uint256_t c = from_buffer<uint256_t>(points_buf.data(), i * COMPRESSED_POINT_SIZE);
37 g1_points[i] = g1::affine_element::from_compressed(c);
41 uncompressed_out.resize(
static_cast<size_t>(num_points) * UNCOMPRESSED_POINT_SIZE);
43 for (
auto i : chunk.
range(
static_cast<size_t>(num_points))) {
45 std::copy(buf.begin(), buf.end(), &uncompressed_out[i * UNCOMPRESSED_POINT_SIZE]);
49 throw_or_abort(
"SrsInitSrs: invalid points_buf size. Expected 32 or 64 bytes per point, got " +
58 auto g2_point_elem = from_buffer<g2::affine_element>(g2_point.data());
59 if (!g2_point_elem.is_in_prime_subgroup()) {
60 throw_or_abort(
"SrsInitSrs: g2_point is not in the BN254 G2 prime-order subgroup");
66 return { .points_buf =
std::move(uncompressed_out) };