Skip to content

Conversation

@nicole-graus
Copy link
Contributor

Add GKR Protocol

Description

An implementation of the Goldwasser-Kalai-Rothblum (GKR) Non-Interactive Protocol for proving correct evaluation of arithmetic circuits.

This implementation follows the steps described in our blog post.

Warning: This GKR implementation is for educational purposes and should not be used in production. It uses the Fiat-Shamir transform, which is vulnerable to practical attacks in this context (see "How to Prove False Statments").

Type of change

Please delete options that are not relevant.

  • New feature
  • Bug fix
  • Optimization

@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2025

Codecov Report

❌ Patch coverage is 93.60374% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.17%. Comparing base (4b01854) to head (3d90a9a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/provers/gkr/src/circuit.rs 85.33% 22 Missing ⚠️
crates/provers/gkr/src/verifier.rs 90.24% 8 Missing ⚠️
crates/provers/gkr/src/sumcheck.rs 94.28% 6 Missing ⚠️
...ates/math/src/polynomial/dense_multilinear_poly.rs 33.33% 2 Missing ⚠️
crates/provers/gkr/src/lib.rs 98.98% 2 Missing ⚠️
crates/provers/gkr/src/prover.rs 99.02% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1011      +/-   ##
==========================================
+ Coverage   69.63%   70.17%   +0.54%     
==========================================
  Files         160      165       +5     
  Lines       32132    32770     +638     
==========================================
+ Hits        22374    22996     +622     
- Misses       9758     9774      +16     

☔ 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.

@nicole-graus nicole-graus marked this pull request as ready for review July 17, 2025 21:20
@nicole-graus nicole-graus requested a review from a team as a code owner July 17, 2025 21:20
Comment on lines 81 to 83
const MODULUS: u64 = 389;
type F = U64PrimeField<MODULUS>;
type FE = FieldElement<F>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to add the suffix to these constants as in MODULUS23, F23 and F23E

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, solved it in b19330f

Comment on lines 82 to 83
for c_idx in 0..(1 << num_vars_next) {
for b_idx in 0..(1 << num_vars_next) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's better to assign this: 1 << num_vars_next to a new variable to avoid repetitive computation

Copy link
Contributor

Choose a reason for hiding this comment

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

Solved in 3d37bb4

Comment on lines 39 to 40
let factors_term_1 = terms[0].clone();
let factors_term_2 = terms[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.

this function should check that terms has at least 2 elements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Done it here.

We also remove the terms[0].is_empty part, because Prover::new() already checks that.

return Err(ProverError::SumcheckError);
}

let factors_term_1 = terms[0].clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

the clone is not necessary, since this function takes ownership of the Vec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done it here.

@jotabulacios jotabulacios added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit 575c4a2 Sep 4, 2025
8 checks passed
@jotabulacios jotabulacios deleted the gkr_protocol branch September 4, 2025 17:45
gabrielbosio pushed a commit that referenced this pull request Sep 23, 2025
* save work, protocol structure now is following the post style

* add prints to debug implementation

* refactor to avoid unwraps

* more refactor

* more refactor

* refactor

* add readme

* Fix readme. Add struct Prover

* remove extra cargo.toml

* remove claimed_sum from sumcheck_proof. Fix test. Add documentation

* remove clones and fix clippy

* add documentation

* add check mark for gkr in readme

* add degree check on g_j

* add verifier checks: proof structure match circuit structure

* fix clippy for new rust version (#1013)

* fix clippy

* fix readme

* rename modulus

* avoid repetitive computation

* check terms has len 2

* remove clone term_1 and term_2

* add check number of inputs

* fix type complexity

---------

Co-authored-by: jotabulacios <jbulacios@fi.uba.ar>
Co-authored-by: jotabulacios <45471455+jotabulacios@users.noreply.github.com>
Co-authored-by: Diego K <43053772+diegokingston@users.noreply.github.com>
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.

6 participants