Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use points map for faster search over the LPC points. #333

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions libs/zk/include/nil/crypto3/zk/commitments/polynomial/lpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ namespace nil {
polynomial_type prepare_combined_Q(
const typename field_type::value_type& theta,
std::size_t starting_power = 0) {
this->build_points_map();

typename field_type::value_type theta_acc = theta.pow(starting_power);
polynomial_type combined_Q;
math::polynomial<value_type> V;
Expand All @@ -290,8 +292,10 @@ namespace nil {
math::polynomial<value_type> Q_normal;
for (std::size_t i: this->_z.get_batches()) {
for (std::size_t j = 0; j < this->_z.get_batch_size(i); j++) {
auto it = std::find(this->_points[i][j].begin(), this->_points[i][j].end(), point);
if( it == this->_points[i][j].end()) continue;
auto iter = this->_points_map[i][j].find(point);
if (iter == this->_points_map[i][j].end())
continue;

math::polynomial<value_type> g_normal;
if constexpr(std::is_same<math::polynomial_dfs<value_type>, PolynomialType>::value ) {
g_normal = math::polynomial<value_type>(this->_polys[i][j].coefficients());
Expand All @@ -300,7 +304,7 @@ namespace nil {
}
g_normal *= theta_acc;
Q_normal += g_normal;
Q_normal -= this->_z.get(i, j, it - this->_points[i][j].begin()) * theta_acc;
Q_normal -= this->_z.get(i, j, iter->second) * theta_acc;
theta_acc *= theta;
}
}
Expand Down
Loading