-
Notifications
You must be signed in to change notification settings - Fork 298
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
Refactor CTL Handling #1629
Merged
Merged
Refactor CTL Handling #1629
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0b557bd
refactor
sai-deng 9fa733e
fmt
sai-deng cd0fa56
fmt
sai-deng 73576c1
sync target version
sai-deng 4226f01
fix
sai-deng 47511bb
fix clippy
sai-deng 8463eff
fix clippy
sai-deng 8b6bbaf
Merge branch 'main' into sai/support_optional_table2
sai-deng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ use crate::lookup::{ | |
eval_helper_columns, eval_helper_columns_circuit, get_grand_product_challenge_set, | ||
get_helper_cols, Column, ColumnFilter, Filter, GrandProductChallenge, GrandProductChallengeSet, | ||
}; | ||
use crate::proof::{MultiProof, StarkProofTarget, StarkProofWithMetadata}; | ||
use crate::proof::StarkProofTarget; | ||
use crate::stark::Stark; | ||
|
||
/// An alias for `usize`, to represent the index of a STARK table in a multi-STARK setting. | ||
|
@@ -250,7 +250,8 @@ where | |
|
||
/// Outputs all the CTL data necessary to prove a multi-STARK system. | ||
pub fn get_ctl_vars_from_proofs<'a, F, C, const D: usize, const N: usize>( | ||
multi_proof: &MultiProof<F, C, D, N>, | ||
auxiliary_polys: &[&Option<Vec<F::Extension>>; N], | ||
auxiliary_polys_next: &[&Option<Vec<F::Extension>>; N], | ||
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. I think these could share the same lifetimes as below |
||
all_cross_table_lookups: &'a [CrossTableLookup<F>], | ||
ctl_challenges: &'a GrandProductChallengeSet<F>, | ||
num_lookup_columns: &'a [usize; N], | ||
|
@@ -264,8 +265,9 @@ where | |
let num_ctl_helper_cols = | ||
num_ctl_helper_columns_by_table(all_cross_table_lookups, max_constraint_degree); | ||
|
||
CtlCheckVars::from_proofs( | ||
&multi_proof.stark_proofs, | ||
CtlCheckVars::from_proofs::<C, N>( | ||
auxiliary_polys, | ||
auxiliary_polys_next, | ||
all_cross_table_lookups, | ||
ctl_challenges, | ||
num_lookup_columns, | ||
|
@@ -491,7 +493,8 @@ impl<'a, F: RichField + Extendable<D>, const D: usize> | |
{ | ||
/// Extracts the `CtlCheckVars` for each STARK. | ||
pub fn from_proofs<C: GenericConfig<D, F = F>, const N: usize>( | ||
proofs: &[StarkProofWithMetadata<F, C, D>; N], | ||
auxiliary_polys: &[&Option<Vec<F::Extension>>; N], | ||
auxiliary_polys_next: &[&Option<Vec<F::Extension>>; N], | ||
cross_table_lookups: &'a [CrossTableLookup<F>], | ||
ctl_challenges: &'a GrandProductChallengeSet<F>, | ||
num_lookup_columns: &[usize; N], | ||
|
@@ -501,10 +504,7 @@ impl<'a, F: RichField + Extendable<D>, const D: usize> | |
// If there are no auxiliary polys in the proofs `openings`, | ||
// return early. The verifier will reject the proofs when | ||
// calling `validate_proof_shape`. | ||
if proofs | ||
.iter() | ||
.any(|p| p.proof.openings.auxiliary_polys.is_none()) | ||
{ | ||
if auxiliary_polys.iter().any(|&aux_polys| aux_polys.is_none()) { | ||
return ctl_vars_per_table; | ||
} | ||
|
||
|
@@ -516,21 +516,20 @@ impl<'a, F: RichField + Extendable<D>, const D: usize> | |
} | ||
|
||
// Get all cross-table lookup polynomial openings for each STARK proof. | ||
let ctl_zs = proofs | ||
let ctl_zs = auxiliary_polys | ||
.iter() | ||
.zip(num_lookup_columns) | ||
.map(|(p, &num_lookup)| { | ||
let openings = &p.proof.openings; | ||
|
||
let ctl_zs = &openings | ||
.auxiliary_polys | ||
.zip(auxiliary_polys_next.iter()) | ||
.zip(num_lookup_columns.iter()) | ||
.map(|((&aux_polys, &aux_polys_next), &num_lookup)| { | ||
// Ensure we have auxiliary polynomials for both current and next steps | ||
let ctl_zs = &aux_polys | ||
.as_ref() | ||
.expect("We cannot have CTls without auxiliary polynomials.")[num_lookup..]; | ||
let ctl_zs_next = &openings | ||
.auxiliary_polys_next | ||
.expect("We cannot have CTLs without auxiliary polynomials.")[num_lookup..]; | ||
let ctl_zs_next = &aux_polys_next | ||
.as_ref() | ||
.expect("We cannot have CTls without auxiliary polynomials.")[num_lookup..]; | ||
ctl_zs.iter().zip(ctl_zs_next).collect::<Vec<_>>() | ||
.expect("We cannot have CTLs without auxiliary polynomials.")[num_lookup..]; | ||
|
||
ctl_zs.iter().zip(ctl_zs_next.iter()).collect::<Vec<_>>() | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: the name is slightly misleading now, as we're not passing the
multi_proof
as arg anymore. What aboutget_ctl_vars_from_aux_polys
?