From 2323cd53486d3a8a063685094ad51aa98412c4a5 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 29 Aug 2024 13:01:38 -0400 Subject: [PATCH] refactor(bb): use std::span in pippenger for scalars (#8269) Refactoring stepping stone. Behaves identically Next step would be to use this to allow accessing power of 2 quantities above the std::span size() (with a different wrapper class) so that non-powers-of-2 can be passed directly to pippenger We recently anted to save memory on polynomials. The idea is that instead of rounding up to a power of 2 to make pippenger fast (at cost of memory), we will make a wrapper class that happily pretends it has T{} (i.e. zeroes) anywhere form 0 to nearest rounded up power of 2. For starters this just introduces a std::span, which should behave identically --- .../benchmark/pippenger_bench/main.cpp | 2 +- .../commitment_schemes/commitment_key.hpp | 4 +- .../commitment_schemes/ipa/ipa.hpp | 8 +-- .../scalar_multiplication.cpp | 52 +++++++++--------- .../scalar_multiplication.hpp | 17 +++--- .../plonk/proof_system/verifier/verifier.cpp | 3 +- .../proof_system/verifier/verifier.test.cpp | 10 ++-- .../plonk/work_queue/work_queue.cpp | 2 +- .../polynomials/legacy_polynomials.bench.cpp | 20 +++---- .../srs/scalar_multiplication.test.cpp | 54 ++++++++++++------- 10 files changed, 97 insertions(+), 75 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp index 8ee44898988..2b6e2caf4a0 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/pippenger_bench/main.cpp @@ -72,7 +72,7 @@ int pippenger() scalar_multiplication::pippenger_runtime_state state(NUM_POINTS); std::chrono::steady_clock::time_point time_start = std::chrono::steady_clock::now(); g1::element result = scalar_multiplication::pippenger_unsafe( - &scalars[0], reference_string->get_monomial_points(), NUM_POINTS, state); + { &scalars[0], /*size*/ NUM_POINTS }, reference_string->get_monomial_points(), NUM_POINTS, state); std::chrono::steady_clock::time_point time_end = std::chrono::steady_clock::now(); std::chrono::microseconds diff = std::chrono::duration_cast(time_end - time_start); std::cout << "run time: " << diff.count() << "us" << std::endl; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp index ab67227424b..4509ba3e405 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.hpp @@ -79,7 +79,7 @@ template class CommitmentKey { ASSERT(false); } return scalar_multiplication::pippenger_unsafe( - const_cast(polynomial.data()), srs->get_monomial_points(), degree, pippenger_runtime_state); + polynomial, srs->get_monomial_points(), degree, pippenger_runtime_state); }; /** @@ -146,7 +146,7 @@ template class CommitmentKey { // Call the version of pippenger which assumes all points are distinct return scalar_multiplication::pippenger_unsafe( - scalars.data(), points.data(), scalars.size(), pippenger_runtime_state); + scalars, points.data(), scalars.size(), pippenger_runtime_state); } }; diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp index d9b627149df..10e8bfbe80f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp @@ -215,13 +215,13 @@ template class IPA { // Step 6.a (using letters, because doxygen automaticall converts the sublist counters to letters :( ) // L_i = < a_vec_lo, G_vec_hi > + inner_prod_L * aux_generator L_i = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( - &a_vec[0], &G_vec_local[round_size], round_size, ck->pippenger_runtime_state); + {&a_vec[0], /*size*/ round_size}, &G_vec_local[round_size], round_size, ck->pippenger_runtime_state); L_i += aux_generator * inner_prod_L; // Step 6.b // R_i = < a_vec_hi, G_vec_lo > + inner_prod_R * aux_generator R_i = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( - &a_vec[round_size], &G_vec_local[0], round_size, ck->pippenger_runtime_state); + {&a_vec[round_size], /*size*/ round_size}, &G_vec_local[0], round_size, ck->pippenger_runtime_state); R_i += aux_generator * inner_prod_R; // Step 6.c @@ -345,7 +345,7 @@ template class IPA { // Step 5. // Compute C₀ = C' + ∑_{j ∈ [k]} u_j^{-1}L_j + ∑_{j ∈ [k]} u_jR_j GroupElement LR_sums = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( - &msm_scalars[0], &msm_elements[0], pippenger_size, vk->pippenger_runtime_state); + {&msm_scalars[0], /*size*/ pippenger_size}, &msm_elements[0], pippenger_size, vk->pippenger_runtime_state); GroupElement C_zero = C_prime + LR_sums; // Step 6. @@ -394,7 +394,7 @@ template class IPA { // Step 8. // Compute G₀ Commitment G_zero = bb::scalar_multiplication::pippenger_without_endomorphism_basis_points( - &s_vec[0], &G_vec_local[0], poly_length, vk->pippenger_runtime_state); + {&s_vec[0], /*size*/ poly_length}, &G_vec_local[0], poly_length, vk->pippenger_runtime_state); // Step 9. // Receive a₀ from the prover diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp index 22e2c72f405..329b8138a1e 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.cpp @@ -199,7 +199,7 @@ template void compute_wnaf_states(uint64_t* point_schedule, bool* input_skew_table, uint64_t* round_counts, - const typename Curve::ScalarField* scalars, + const std::span scalars, const size_t num_initial_points) { using Fr = typename Curve::ScalarField; @@ -857,7 +857,7 @@ typename Curve::Element evaluate_pippenger_rounds(pippenger_runtime_state template typename Curve::Element pippenger_internal(typename Curve::AffineElement* points, - typename Curve::ScalarField* scalars, + std::span scalars, const size_t num_initial_points, pippenger_runtime_state& state, bool handle_edge_cases) @@ -871,7 +871,7 @@ typename Curve::Element pippenger_internal(typename Curve::AffineElement* points } template -typename Curve::Element pippenger(typename Curve::ScalarField* scalars, +typename Curve::Element pippenger(std::span scalars, typename Curve::AffineElement* points, const size_t num_initial_points, pippenger_runtime_state& state, @@ -910,10 +910,9 @@ typename Curve::Element pippenger(typename Curve::ScalarField* scalars, const auto num_slice_points = static_cast(1ULL << slice_bits); Element result = pippenger_internal(points, scalars, num_slice_points, state, handle_edge_cases); - if (num_slice_points != num_initial_points) { const uint64_t leftover_points = num_initial_points - num_slice_points; - return result + pippenger(scalars + num_slice_points, + return result + pippenger(scalars.subspan(num_slice_points), points + static_cast(num_slice_points * 2), static_cast(leftover_points), state, @@ -938,7 +937,7 @@ typename Curve::Element pippenger(typename Curve::ScalarField* scalars, * **/ template -typename Curve::Element pippenger_unsafe(typename Curve::ScalarField* scalars, +typename Curve::Element pippenger_unsafe(std::span scalars, typename Curve::AffineElement* points, const size_t num_initial_points, pippenger_runtime_state& state) @@ -947,10 +946,11 @@ typename Curve::Element pippenger_unsafe(typename Curve::ScalarField* scalars, } template -typename Curve::Element pippenger_without_endomorphism_basis_points(typename Curve::ScalarField* scalars, - typename Curve::AffineElement* points, - const size_t num_initial_points, - pippenger_runtime_state& state) +typename Curve::Element pippenger_without_endomorphism_basis_points( + std::span scalars, + typename Curve::AffineElement* points, + const size_t num_initial_points, + pippenger_runtime_state& state) { std::vector G_mod(num_initial_points * 2); bb::scalar_multiplication::generate_pippenger_point_table(points, &G_mod[0], num_initial_points); @@ -978,7 +978,7 @@ template void evaluate_addition_chains(affine_product_runtime_stat const size_t max_bucket_bits, bool handle_edge_cases); template curve::BN254::Element pippenger_internal(curve::BN254::AffineElement* points, - curve::BN254::ScalarField* scalars, + std::span scalars, const size_t num_initial_points, pippenger_runtime_state& state, bool handle_edge_cases); @@ -992,19 +992,19 @@ template curve::BN254::AffineElement* reduce_buckets(affine_produc bool first_round = true, bool handle_edge_cases = false); -template curve::BN254::Element pippenger(curve::BN254::ScalarField* scalars, +template curve::BN254::Element pippenger(std::span scalars, curve::BN254::AffineElement* points, const size_t num_points, pippenger_runtime_state& state, bool handle_edge_cases = true); -template curve::BN254::Element pippenger_unsafe(curve::BN254::ScalarField* scalars, +template curve::BN254::Element pippenger_unsafe(std::span scalars, curve::BN254::AffineElement* points, const size_t num_initial_points, pippenger_runtime_state& state); template curve::BN254::Element pippenger_without_endomorphism_basis_points( - curve::BN254::ScalarField* scalars, + std::span scalars, curve::BN254::AffineElement* points, const size_t num_initial_points, pippenger_runtime_state& state); @@ -1028,11 +1028,12 @@ template void add_affine_points_with_edge_cases(curve::Grumpkin template void evaluate_addition_chains(affine_product_runtime_state& state, const size_t max_bucket_bits, bool handle_edge_cases); -template curve::Grumpkin::Element pippenger_internal(curve::Grumpkin::AffineElement* points, - curve::Grumpkin::ScalarField* scalars, - const size_t num_initial_points, - pippenger_runtime_state& state, - bool handle_edge_cases); +template curve::Grumpkin::Element pippenger_internal( + curve::Grumpkin::AffineElement* points, + std::span scalars, + const size_t num_initial_points, + pippenger_runtime_state& state, + bool handle_edge_cases); template curve::Grumpkin::Element evaluate_pippenger_rounds( pippenger_runtime_state& state, @@ -1043,19 +1044,20 @@ template curve::Grumpkin::Element evaluate_pippenger_rounds( template curve::Grumpkin::AffineElement* reduce_buckets( affine_product_runtime_state& state, bool first_round = true, bool handle_edge_cases = false); -template curve::Grumpkin::Element pippenger(curve::Grumpkin::ScalarField* scalars, +template curve::Grumpkin::Element pippenger(std::span scalars, curve::Grumpkin::AffineElement* points, const size_t num_points, pippenger_runtime_state& state, bool handle_edge_cases = true); -template curve::Grumpkin::Element pippenger_unsafe(curve::Grumpkin::ScalarField* scalars, - curve::Grumpkin::AffineElement* points, - const size_t num_initial_points, - pippenger_runtime_state& state); +template curve::Grumpkin::Element pippenger_unsafe( + std::span scalars, + curve::Grumpkin::AffineElement* points, + const size_t num_initial_points, + pippenger_runtime_state& state); template curve::Grumpkin::Element pippenger_without_endomorphism_basis_points( - curve::Grumpkin::ScalarField* scalars, + std::span scalars, curve::Grumpkin::AffineElement* points, const size_t num_initial_points, pippenger_runtime_state& state); diff --git a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp index c93b602bfe1..f178023b325 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp @@ -89,7 +89,7 @@ template void compute_wnaf_states(uint64_t* point_schedule, bool* input_skew_table, uint64_t* round_counts, - const typename Curve::ScalarField* scalars, + std::span scalars, size_t num_initial_points); template @@ -135,7 +135,7 @@ void evaluate_addition_chains(affine_product_runtime_state& state, bool handle_edge_cases); template typename Curve::Element pippenger_internal(typename Curve::AffineElement* points, - typename Curve::ScalarField* scalars, + std::span scalars, size_t num_initial_points, pippenger_runtime_state& state, bool handle_edge_cases); @@ -152,23 +152,24 @@ typename Curve::AffineElement* reduce_buckets(affine_product_runtime_state -typename Curve::Element pippenger(typename Curve::ScalarField* scalars, +typename Curve::Element pippenger(std::span scalars, typename Curve::AffineElement* points, size_t num_initial_points, pippenger_runtime_state& state, bool handle_edge_cases = true); template -typename Curve::Element pippenger_unsafe(typename Curve::ScalarField* scalars, +typename Curve::Element pippenger_unsafe(std::span scalars, typename Curve::AffineElement* points, size_t num_initial_points, pippenger_runtime_state& state); template -typename Curve::Element pippenger_without_endomorphism_basis_points(typename Curve::ScalarField* scalars, - typename Curve::AffineElement* points, - size_t num_initial_points, - pippenger_runtime_state& state); +typename Curve::Element pippenger_without_endomorphism_basis_points( + std::span scalars, + typename Curve::AffineElement* points, + size_t num_initial_points, + pippenger_runtime_state& state); // Explicit instantiation // BN254 diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp index db39862b02e..dd8c4d2a6f3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.cpp @@ -182,7 +182,8 @@ template bool VerifierBase::verify g1::element P[2]; - P[0] = bb::scalar_multiplication::pippenger(&scalars[0], &elements[0], num_elements, state); + P[0] = bb::scalar_multiplication::pippenger( + { &scalars[0], num_elements }, &elements[0], num_elements, state); P[1] = -(g1::element(PI_Z_OMEGA) * separator_challenge + PI_Z); if (key->contains_recursive_proof) { diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp index 683145c85b8..427108062ec 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp @@ -33,11 +33,11 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k commitments.resize(8); for (size_t i = 0; i < 8; ++i) { - commitments[i] = g1::affine_element( - scalar_multiplication::pippenger(poly_coefficients[i].get(), - circuit_proving_key->reference_string->get_monomial_points(), - circuit_proving_key->circuit_size, - state)); + commitments[i] = g1::affine_element(scalar_multiplication::pippenger( + { poly_coefficients[i].get(), circuit_proving_key->circuit_size }, + circuit_proving_key->reference_string->get_monomial_points(), + circuit_proving_key->circuit_size, + state)); } auto crs = std::make_shared>("../srs_db/ignition"); diff --git a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp index 571876b06c6..e6308a8343f 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/work_queue/work_queue.cpp @@ -214,7 +214,7 @@ void work_queue::process_queue() // Run pippenger multi-scalar multiplication. auto runtime_state = bb::scalar_multiplication::pippenger_runtime_state(msm_size); bb::g1::affine_element result(bb::scalar_multiplication::pippenger_unsafe( - item.mul_scalars.get(), srs_points, msm_size, runtime_state)); + { item.mul_scalars.get(), msm_size }, srs_points, msm_size, runtime_state)); transcript->add_element(item.tag, result.to_buffer()); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/legacy_polynomials.bench.cpp b/barretenberg/cpp/src/barretenberg/polynomials/legacy_polynomials.bench.cpp index 5a3ead7a0d3..716c79d8600 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/legacy_polynomials.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/legacy_polynomials.bench.cpp @@ -124,7 +124,7 @@ void pippenger_bench(State& state) noexcept state.ResumeTiming(); // uint64_t before = rdtsc(); scalar_multiplication::pippenger( - &globals.scalars[0], &globals.monomials[0], num_points, run_state); + { &globals.scalars[0], /*size*/ num_points }, &globals.monomials[0], num_points, run_state); // uint64_t after = rdtsc(); // count += (after - before); // ++i; @@ -169,23 +169,23 @@ void new_plonk_scalar_multiplications_bench(State& state) noexcept uint64_t before = rdtsc(); g1::element a = scalar_multiplication::pippenger( - &globals.scalars[0], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[0], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element b = scalar_multiplication::pippenger( - &globals.scalars[1], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[1], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element c = scalar_multiplication::pippenger( - &globals.scalars[2], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[2], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element d = scalar_multiplication::pippenger( - &globals.scalars[3], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[3], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element e = scalar_multiplication::pippenger( - &globals.scalars[4], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[4], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element f = scalar_multiplication::pippenger( - &globals.scalars[5], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[5], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element g = scalar_multiplication::pippenger( - &globals.scalars[6], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[6], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element h = scalar_multiplication::pippenger( - &globals.scalars[7], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[7], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); g1::element i = scalar_multiplication::pippenger( - &globals.scalars[8], &globals.monomials[0], MAX_GATES, run_state); + { &globals.scalars[8], /*size*/ MAX_GATES }, &globals.monomials[0], MAX_GATES, run_state); uint64_t after = rdtsc(); count += (after - before); ++k; diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index d66641157a5..660339f674e 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -285,8 +285,11 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) scalar_multiplication::pippenger_runtime_state state(num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( - state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); + scalar_multiplication::compute_wnaf_states(state.point_schedule, + state.skew_table, + state.round_counts, + { scalars, /*size*/ num_initial_points }, + num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; @@ -405,8 +408,11 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( - state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); + scalar_multiplication::compute_wnaf_states(state.point_schedule, + state.skew_table, + state.round_counts, + { scalars, /*size*/ num_initial_points }, + num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; @@ -513,8 +519,11 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( - state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); + scalar_multiplication::compute_wnaf_states(state.point_schedule, + state.skew_table, + state.round_counts, + { scalars, /*size*/ num_initial_points }, + num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; @@ -611,7 +620,7 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) scalar_multiplication::pippenger_runtime_state state(target_degree); scalar_multiplication::compute_wnaf_states( - state.point_schedule, state.skew_table, state.round_counts, scalars, target_degree); + state.point_schedule, state.skew_table, state.round_counts, { scalars, /*size*/ target_degree }, target_degree); uint64_t* wnaf_copy = (uint64_t*)(aligned_alloc(64, sizeof(uint64_t) * target_degree * 2 * num_rounds)); memcpy((void*)wnaf_copy, (void*)state.point_schedule, sizeof(uint64_t) * target_degree * 2 * num_rounds); @@ -672,7 +681,8 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) } scalar_multiplication::pippenger_runtime_state state(target_degree); - Element first = scalar_multiplication::pippenger(scalars, monomials, target_degree, state); + Element first = + scalar_multiplication::pippenger({ scalars, /*size*/ target_degree }, monomials, target_degree, state); first = first.normalize(); for (size_t i = 0; i < target_degree; ++i) { @@ -680,7 +690,8 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) } scalar_multiplication::pippenger_runtime_state state_2(target_degree); - Element second = scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); + Element second = + scalar_multiplication::pippenger({ scalars, /*size*/ target_degree }, monomials, target_degree, state_2); second = second.normalize(); EXPECT_EQ((first.z == second.z), true); @@ -723,7 +734,8 @@ TYPED_TEST(ScalarMultiplicationTests, UndersizedInputs) scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = + scalar_multiplication::pippenger({ scalars, /*size*/ num_points }, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -760,7 +772,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerSmall) scalar_multiplication::generate_pippenger_point_table(points, points, num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = + scalar_multiplication::pippenger({ scalars, /*size*/ num_points }, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -799,7 +812,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerEdgeCaseDbl) } scalar_multiplication::generate_pippenger_point_table(points, points, num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = + scalar_multiplication::pippenger({ scalars, /*size*/ num_points }, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -857,7 +871,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points.get(), num_points, state); + Element result = + scalar_multiplication::pippenger({ scalars, /*size*/ num_points }, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -893,7 +908,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); + Element result = scalar_multiplication::pippenger_unsafe( + { scalars, /*size*/ num_points }, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -950,7 +966,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafeShortInputs) scalar_multiplication::generate_pippenger_point_table(points, points, num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); + Element result = + scalar_multiplication::pippenger_unsafe({ scalars, /*size*/ num_points }, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -987,7 +1004,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerOne) scalar_multiplication::generate_pippenger_point_table(points, points, num_points); scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = + scalar_multiplication::pippenger({ scalars, /*size*/ num_points }, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -1008,7 +1026,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerZeroPoints) AffineElement* points = (AffineElement*)aligned_alloc(32, sizeof(AffineElement) * (2 + 1)); scalar_multiplication::pippenger_runtime_state state(0); - Element result = scalar_multiplication::pippenger(scalars, points, 0, state); + Element result = scalar_multiplication::pippenger({ scalars, /*size*/ 0 }, points, 0, state); aligned_free(scalars); aligned_free(points); @@ -1033,7 +1051,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerMulByZero) scalar_multiplication::generate_pippenger_point_table(points, points, 1); scalar_multiplication::pippenger_runtime_state state(1); - Element result = scalar_multiplication::pippenger(scalars, points, 1, state); + Element result = scalar_multiplication::pippenger({ scalars, /*size*/ 1 }, points, 1, state); aligned_free(scalars); aligned_free(points);