-
Notifications
You must be signed in to change notification settings - Fork 176
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 support for periodic columns in LogUp-GKR #307
Changes from 24 commits
8ac25c7
5e06378
16389d6
380aa1a
7a1a99e
1901066
8a57216
ff9e6fa
7e24f8f
23044e8
ad0497d
a0272ea
7b8caff
e2b8c12
b813916
492f247
0d664e0
8617308
ed781d8
98c0e71
807aba1
4e6d3ab
c93ec35
873345a
d94794a
b484e04
dec6589
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,7 +5,7 @@ | |||||
|
||||||
use alloc::vec::Vec; | ||||||
|
||||||
use air::LogUpGkrEvaluator; | ||||||
use air::{LogUpGkrEvaluator, PeriodicTable}; | ||||||
use crypto::{ElementHasher, RandomCoin}; | ||||||
use math::FieldElement; | ||||||
#[cfg(feature = "concurrent")] | ||||||
|
@@ -160,6 +160,7 @@ pub fn sum_check_prove_higher_degree< | |||||
r_sum_check: E, | ||||||
log_up_randomness: Vec<E>, | ||||||
mut mls: Vec<MultiLinearPoly<E>>, | ||||||
mut periodic_table: PeriodicTable<E>, | ||||||
coin: &mut impl RandomCoin<Hasher = H, BaseField = E::BaseField>, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We can pass this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
) -> Result<SumCheckProof<E>, SumCheckProverError> { | ||||||
let num_rounds = mls[0].num_variables(); | ||||||
|
@@ -176,8 +177,15 @@ pub fn sum_check_prove_higher_degree< | |||||
let mut current_round_claim = SumCheckRoundClaim { eval_point: vec![], claim }; | ||||||
|
||||||
// run the first round of the protocol | ||||||
let round_poly_evals = | ||||||
sumcheck_round(&eq_mu, evaluator, &eq_nu, &mls, &log_up_randomness, r_sum_check); | ||||||
let round_poly_evals = sumcheck_round( | ||||||
&eq_mu, | ||||||
evaluator, | ||||||
&eq_nu, | ||||||
&mls, | ||||||
&mut periodic_table, | ||||||
&log_up_randomness, | ||||||
r_sum_check, | ||||||
); | ||||||
let round_poly_coefs = round_poly_evals.to_poly(current_round_claim.claim); | ||||||
|
||||||
// reseed with the s_0 polynomial | ||||||
|
@@ -198,10 +206,20 @@ pub fn sum_check_prove_higher_degree< | |||||
.for_each(|ml| ml.bind_least_significant_variable(round_challenge)); | ||||||
eq_nu.bind_least_significant_variable(round_challenge); | ||||||
|
||||||
// fold each periodic multi-linear using the round challenge | ||||||
periodic_table.bind_least_significant_variable(round_challenge); | ||||||
|
||||||
// run the i-th round of the protocol using the folded multi-linears for the new reduced | ||||||
// claim. This basically computes the s_i polynomial. | ||||||
let round_poly_evals = | ||||||
sumcheck_round(&eq_mu, evaluator, &eq_nu, &mls, &log_up_randomness, r_sum_check); | ||||||
let round_poly_evals = sumcheck_round( | ||||||
&eq_mu, | ||||||
evaluator, | ||||||
&eq_nu, | ||||||
&mls, | ||||||
&mut periodic_table, | ||||||
&log_up_randomness, | ||||||
r_sum_check, | ||||||
); | ||||||
|
||||||
// update the claim | ||||||
current_round_claim = new_round_claim; | ||||||
|
@@ -280,21 +298,23 @@ fn sumcheck_round<E: FieldElement>( | |||||
evaluator: &impl LogUpGkrEvaluator<BaseField = <E as FieldElement>::BaseField>, | ||||||
eq_ml: &MultiLinearPoly<E>, | ||||||
mls: &[MultiLinearPoly<E>], | ||||||
periodic_table: &mut PeriodicTable<E>, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Fixed |
||||||
log_up_randomness: &[E], | ||||||
r_sum_check: E, | ||||||
) -> CompressedUnivariatePolyEvals<E> { | ||||||
let num_ml = mls.len(); | ||||||
let num_mls = mls.len(); | ||||||
let num_oracles = num_mls + periodic_table.num_columns(); | ||||||
let num_vars = mls[0].num_variables(); | ||||||
let num_rounds = num_vars - 1; | ||||||
|
||||||
#[cfg(not(feature = "concurrent"))] | ||||||
let evaluations = { | ||||||
let mut evals_one = vec![E::ZERO; num_ml]; | ||||||
let mut evals_zero = vec![E::ZERO; num_ml]; | ||||||
let mut evals_x = vec![E::ZERO; num_ml]; | ||||||
let mut evals_one = vec![E::ZERO; num_oracles]; | ||||||
let mut evals_zero = vec![E::ZERO; num_oracles]; | ||||||
let mut evals_x = vec![E::ZERO; num_oracles]; | ||||||
let mut eq_x = E::ZERO; | ||||||
|
||||||
let mut deltas = vec![E::ZERO; num_ml]; | ||||||
let mut deltas = vec![E::ZERO; num_oracles]; | ||||||
let mut eq_delta = E::ZERO; | ||||||
|
||||||
let mut numerators = vec![E::ZERO; evaluator.get_num_fractions()]; | ||||||
|
@@ -311,6 +331,10 @@ fn sumcheck_round<E: FieldElement>( | |||||
let eq_at_zero = eq_ml.evaluations()[2 * i]; | ||||||
let eq_at_one = eq_ml.evaluations()[2 * i + 1]; | ||||||
|
||||||
// add evaluation of periodic columns | ||||||
periodic_table.fill_periodic_values_at(2 * i, &mut evals_zero[num_mls..]); | ||||||
periodic_table.fill_periodic_values_at(2 * i + 1, &mut evals_one[num_mls..]); | ||||||
|
||||||
// compute the evaluation at 1 | ||||||
evaluator.evaluate_query( | ||||||
&evals_one, | ||||||
|
@@ -327,7 +351,7 @@ fn sumcheck_round<E: FieldElement>( | |||||
); | ||||||
|
||||||
// compute the evaluations at 2, ..., d_max points | ||||||
for i in 0..num_ml { | ||||||
for i in 0..num_oracles { | ||||||
deltas[i] = evals_one[i] - evals_zero[i]; | ||||||
evals_x[i] = evals_one[i]; | ||||||
} | ||||||
|
@@ -371,13 +395,13 @@ fn sumcheck_round<E: FieldElement>( | |||||
.fold( | ||||||
|| { | ||||||
( | ||||||
vec![E::ZERO; num_ml], | ||||||
vec![E::ZERO; num_ml], | ||||||
vec![E::ZERO; num_ml], | ||||||
vec![E::ZERO; num_oracles], | ||||||
vec![E::ZERO; num_oracles], | ||||||
vec![E::ZERO; num_oracles], | ||||||
vec![E::ZERO; evaluator.max_degree()], | ||||||
vec![E::ZERO; evaluator.get_num_fractions()], | ||||||
vec![E::ZERO; evaluator.get_num_fractions()], | ||||||
vec![E::ZERO; num_ml], | ||||||
vec![E::ZERO; num_oracles], | ||||||
) | ||||||
}, | ||||||
|( | ||||||
|
@@ -398,6 +422,10 @@ fn sumcheck_round<E: FieldElement>( | |||||
let eq_at_zero = eq_ml.evaluations()[2 * i]; | ||||||
let eq_at_one = eq_ml.evaluations()[2 * i + 1]; | ||||||
|
||||||
// add evaluation of periodic columns | ||||||
periodic_table.fill_periodic_values_at(2 * i, &mut evals_zero[num_mls..]); | ||||||
periodic_table.fill_periodic_values_at(2 * i + 1, &mut evals_one[num_mls..]); | ||||||
|
||||||
// compute the evaluation at 1 | ||||||
evaluator.evaluate_query( | ||||||
&evals_one, | ||||||
|
@@ -414,7 +442,7 @@ fn sumcheck_round<E: FieldElement>( | |||||
); | ||||||
|
||||||
// compute the evaluations at 2, ..., d_max points | ||||||
for i in 0..num_ml { | ||||||
for i in 0..num_oracles { | ||||||
deltas[i] = evals_one[i] - evals_zero[i]; | ||||||
evals_x[i] = evals_one[i]; | ||||||
} | ||||||
|
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.
E
is not used, and it is redundant, right? It seems like we could always makeF::BaseField
the basefield, andF
the extension field (orF::BaseField
andF
both be the base field).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 for the suggestion, switched to it
Indeed, the generic is redundant now, it is a leftover from a previous iteration. Removed now