Skip to content

Sumcheck integration #977

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

Merged
merged 11 commits into from
Mar 18, 2025
Merged

Sumcheck integration #977

merged 11 commits into from
Mar 18, 2025

Conversation

jotabulacios
Copy link
Contributor

Sumcheck integration

Description

This PR is a follow-up to PR #973. It completes the integration of the Sumcheck protocol by adding complete proof generation and verification functionality.
It also adds a README describing the protocol

Type of change

Please delete options that are not relevant.

  • New feature
  • Bug fix
  • Optimization

Checklist

  • Linked to Github Issue
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 93.42857% with 23 lines in your changes missing coverage. Please review.

Project coverage is 72.02%. Comparing base (98d7d8c) to head (2afdd6f).

Files with missing lines Patch % Lines
provers/sumcheck/src/verifier.rs 77.08% 11 Missing ⚠️
provers/sumcheck/src/lib.rs 97.70% 6 Missing ⚠️
provers/sumcheck/src/prover.rs 85.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #977      +/-   ##
==========================================
+ Coverage   71.99%   72.02%   +0.03%     
==========================================
  Files         159      159              
  Lines       34792    34892     +100     
==========================================
+ Hits        25047    25130      +83     
- Misses       9745     9762      +17     

☔ 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 March 13, 2025 17:57
@jotabulacios jotabulacios requested a review from a team as a code owner March 13, 2025 17:57
The Sumcheck Protocol allows a prover to convince a verifier that the sum of a multivariate polynomial over the Boolean hypercube equals a claimed value, without the verifier having to compute the entire sum.

The protocol proceeds in rounds, with one round per variable of the multivariate polynomial. In each round, the prover sends a univariate polynomial, and the verifier responds with a random challenge. This process reduces a claim about a multivariate polynomial to a claim about a single evaluation point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is an essential building block for many SNARK protocols, given that it reduces the complexity of computing the sum to summing O(\nu) elements, plus an evaluation at a random point.

FE::from(11),
]);

let (claimed_sum, proof_polys) = prove(poly.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

In future versions, it would be better to work directly with a reference to poly

let c_1 = prover.c_1();
println!("\nInitial claimed sum c₁: {:?}", c_1);
let mut transcript = DefaultTranscript::<F>::default();
let mut verifier = verifier::Verifier::new(poly.num_vars(), Some(poly), c_1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typically, we do not want to have the verifier access to the polynomial; this is replaced by an oracle to the polynomial (in the non-interactive version, it has a commitment to P, plus an evaluation proof at r)

let univar = prover.poly.to_univariate();
proof_polys.push(univar.clone());

transcript.append_felt(&univar.coefficients[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have to append the total sum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ab91ea5


// Only generate next challenge if this isn't the final round
if round < n - 2 {
transcript.append_felt(&univar.coefficients[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

intermediate sums should also be committed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ab91ea5

assert!(ok, "Final round verification failed");
break;
for (i, univar) in proof_polys.into_iter().enumerate() {
match verifier.do_round(univar, &mut transcript)? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

check that all elements appended by the prover are appended by the verifier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ab91ea5

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we're deleting all the tests in this file? Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved them to lib.rs. Should I put them back in verifier.rs ?

@diegokingston diegokingston added this pull request to the merge queue Mar 18, 2025
Merged via the queue into main with commit 585fed9 Mar 18, 2025
8 checks passed
@diegokingston diegokingston deleted the sumcheck_integration branch March 18, 2025 14:11
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