Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
batch_mul_native.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
10#include <vector>
11
12namespace bb {
13
14// TODO(https://github.com/AztecProtocol/barretenberg/issues/1552): Optimize batch_mul_native
19template <typename Commitment, typename FF>
20static Commitment batch_mul_native(const std::vector<Commitment>& _points, const std::vector<FF>& _scalars)
21{
22 std::vector<Commitment> points;
23 std::vector<FF> scalars;
24 for (size_t i = 0; i < _points.size(); ++i) {
25 const auto& point = _points[i];
26 const auto& scalar = _scalars[i];
27
28 // TODO: Special handling of point at infinity here due to incorrect serialization.
29 if (!scalar.is_zero() && !point.is_point_at_infinity() && !point.y.is_zero()) {
30 points.emplace_back(point);
31 scalars.emplace_back(scalar);
32 }
33 }
34
35 if (points.empty()) {
36 return Commitment::infinity();
37 }
38
39 auto result = points[0] * scalars[0];
40 for (size_t idx = 1; idx < scalars.size(); ++idx) {
41 result = result + points[idx] * scalars[idx];
42 }
43 return result;
44}
45
46} // namespace bb
Entry point for Barretenberg command-line interface.