Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
batched_affine_addition.test.cpp
Go to the documentation of this file.
6
7#include <cstddef>
8#include <vector>
9
10namespace bb {
11
12namespace {
14}
15
16template <typename Curve> class BatchedAffineAdditionTests : public ::testing::Test {
17
18 public:
19 using G1 = typename Curve::AffineElement;
20 using Fr = typename Curve::ScalarField;
21};
22
23using Curves = ::testing::Types<curve::BN254, curve::Grumpkin>;
24
26
27// Test the method for summing one or more large sequences of affine EC points in place
29{
30 using Curve = TypeParam;
32 using BatchedAddition = BatchedAffineAddition<Curve>;
33
34 // Construct a single array of random points containing 5 sequences to be summed
35 const size_t num_sequences = 5;
36 const size_t sequence_size = 1 << 10;
37 const size_t input_size = num_sequences * sequence_size;
38 std::vector<size_t> sequence_counts(num_sequences, sequence_size);
39
40 // Extract raw SRS points from point point table points
41 std::vector<G1> points;
42 points.reserve(input_size);
43 for (size_t i = 0; i < input_size; ++i) {
44 points.emplace_back(G1::random_element());
45 }
46
47 // Manually sum the points in each sequence to get the expected num-sequences-many reduced points
48 std::vector<G1> expected_reduced_points;
49 size_t point_idx = 0;
50 for (size_t i = 0; i < num_sequences; ++i) {
51 G1 sum = G1::infinity();
52 for (size_t j = 0; j < sequence_size; ++j) {
53 sum = sum + points[point_idx++];
54 }
55 expected_reduced_points.push_back(sum);
56 }
57
58 // Reduce the points using the optimized method
59 auto reduced_points = BatchedAddition::add_in_place(points, sequence_counts);
60
61 // Check agreement of the reduced points
62 for (auto [result, expected] : zip_view(reduced_points, expected_reduced_points)) {
63 EXPECT_EQ(result, expected);
64 }
65}
66} // namespace bb
Class for handling fast batched affine addition of large sets of EC points.
typename Group::affine_element AffineElement
Definition grumpkin.hpp:56
numeric::RNG & engine
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
Definition engine.cpp:190
Entry point for Barretenberg command-line interface.
TYPED_TEST_SUITE(ShpleminiTest, TestSettings)
Inner sum(Cont< Inner, Args... > const &in)
Definition container.hpp:70
TYPED_TEST(ShpleminiTest, CorrectnessOfMultivariateClaimBatching)
::testing::Types< curve::BN254, curve::Grumpkin > Curves
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Curve::AffineElement G1