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

Add sumcheck protocol #973

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add sumcheck protocol #973

wants to merge 12 commits into from

Conversation

jotabulacios
Copy link
Contributor

@jotabulacios jotabulacios commented Feb 25, 2025

Add sumcheck protocol

Description

This PR introduces a basic naive implementation of the Sumcheck Protocol using Multilinear Polynomials.

Type of change

  • New feature
  • Bug fix
  • Optimization

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 95.57740% with 18 lines in your changes missing coverage. Please review.

Project coverage is 71.90%. Comparing base (be4a329) to head (c8f3822).

Files with missing lines Patch % Lines
provers/sumcheck/src/verifier.rs 95.19% 15 Missing ⚠️
math/src/polynomial/dense_multilinear_poly.rs 95.65% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #973      +/-   ##
==========================================
+ Coverage   71.66%   71.90%   +0.24%     
==========================================
  Files         156      159       +3     
  Lines       34316    34659     +343     
==========================================
+ Hits        24593    24923     +330     
- Misses       9723     9736      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jotabulacios jotabulacios marked this pull request as ready for review February 27, 2025 20:14
@jotabulacios jotabulacios requested a review from a team as a code owner February 27, 2025 20:14
poly_evals.push(FieldElement::zero());
}

DenseMultilinearPolynomial {
evals: poly_evals.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if we can avoid this clone

let half = 1 << (n - 1);
let new_evals: Vec<FieldElement<F>> = (0..half)
.map(|j| {
let a = self.evals[j].clone();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, would be better to work with references

}
evaluations.push(self.evaluate(point).unwrap());
}
evaluations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are in Lagrange basis, this is just returning the elements contained in the vector defining the polynomial


pub trait Channel<F: IsField> {
fn append_field_element(&mut self, element: &FieldElement<F>);
fn draw_felt(&mut self) -> FieldElement<F>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would use consistent naming

let eval_1 = univar.evaluate(&FieldElement::<F>::one());

if self.round == 0 {
println!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we keeping the println? The way I see this, the protocol works so long as the polynomial is multilinear

@@ -9,3 +9,4 @@ pub mod errors;
pub mod fiat_shamir;
pub mod hash;
pub mod merkle_tree;
//pub mod sumcheck;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you comment this line? it's better to remove it

@@ -9,3 +9,4 @@ pub mod errors;
pub mod fiat_shamir;
pub mod hash;
pub mod merkle_tree;
//pub mod sumcheck;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented?

}

/// Constructs a DenseMultilinearPolynomial from a vector of evaluations and the number of variables.
pub fn from_evaluations_vec(num_vars: usize, evaluations: Vec<FieldElement<F>>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function could be implemented using the From trait

});
}
} else {
let sum = eval_0.clone() + eval_1.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to sum without clonning the elements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants