-
Notifications
You must be signed in to change notification settings - Fork 179
Add GKR Protocol #1011
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 GKR Protocol #1011
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
e5d7ac2 to
55f0f95
Compare
crates/provers/gkr/src/lib.rs
Outdated
| const MODULUS: u64 = 389; | ||
| type F = U64PrimeField<MODULUS>; | ||
| type FE = FieldElement<F>; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
crates/provers/gkr/src/prover.rs
Outdated
| for c_idx in 0..(1 << num_vars_next) { | ||
| for b_idx in 0..(1 << num_vars_next) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved in 3d37bb4
crates/provers/gkr/src/sumcheck.rs
Outdated
| let factors_term_1 = terms[0].clone(); | ||
| let factors_term_2 = terms[1].clone(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
crates/provers/gkr/src/sumcheck.rs
Outdated
| return Err(ProverError::SumcheckError); | ||
| } | ||
|
|
||
| let factors_term_1 = terms[0].clone(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done it here.
* 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>
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.