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 polynomial_sum instead of naive sum [SyncWith: crypto3-math#87] #333

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,14 @@ namespace nil {

F_dfs[3] = zero_polynomial;

for (std::size_t i = 1; i < sorted.size(); i++) {
typename FieldType::value_type alpha = transcript.template challenge<FieldType>();
math::polynomial_dfs sorted_shifted = math::polynomial_shift(sorted[i-1], preprocessed_data.common_data.desc.usable_rows_amount , basic_domain->m);
F_dfs[3] += alpha * preprocessed_data.common_data.lagrange_0 * (sorted[i] - sorted_shifted);
std::vector<math::polynomial_dfs<typename FieldType::value_type>> F_dfs_3_parts(std::next(sorted.begin(), 1), sorted.end());
for (std::size_t i = 0; i < F_dfs_3_parts.size(); i++) {
typename FieldType::value_type alpha = transcript.template challenge<FieldType>();
math::polynomial_dfs sorted_shifted = math::polynomial_shift(sorted[i], preprocessed_data.common_data.desc.usable_rows_amount , basic_domain->m);
F_dfs_3_parts[i] -= sorted_shifted;
F_dfs_3_parts[i] *= alpha * preprocessed_data.common_data.lagrange_0;
}

/* for( std::size_t i = 0; i < basic_domain->m; i++){
BOOST_CHECK( F_dfs[0].evaluate(basic_domain->get_domain_element(i)) == FieldType::value_type::zero() );
BOOST_CHECK( F_dfs[1].evaluate(basic_domain->get_domain_element(i)) == FieldType::value_type::zero() );
BOOST_CHECK( F_dfs[2].evaluate(basic_domain->get_domain_element(i)) == FieldType::value_type::zero() );
BOOST_CHECK( F_dfs[3].evaluate(basic_domain->get_domain_element(i)) == FieldType::value_type::zero() );
}*/
F_dfs[3] = polynomial_sum<FieldType>(std::move(F_dfs_3_parts));

return {
std::move(F_dfs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ namespace nil {
transcript.template challenges<FieldType, f_parts>();

// 7.2. Compute F_consolidated
polynomial_dfs_type F_consolidated_dfs(
0, _F_dfs[0].size(), FieldType::value_type::zero());
for (std::size_t i = 0; i < f_parts; i++) {
std::vector<polynomial_dfs_type> F_consolidated_dfs_parts(_F_dfs.begin(), _F_dfs.end());
for (std::size_t i = 0; i < F_consolidated_dfs_parts.size(); ++i) {
if (_F_dfs[i].is_zero()) {
continue;
}
F_consolidated_dfs += alphas[i] * _F_dfs[i];
F_consolidated_dfs_parts[i] *= alphas[i];
}
polynomial_dfs_type F_consolidated_dfs = polynomial_sum<FieldType>(std::move(F_consolidated_dfs_parts));

polynomial_type F_consolidated_normal(F_consolidated_dfs.coefficients());

Expand Down
Loading