-
Notifications
You must be signed in to change notification settings - Fork 109
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 eq evals constraints #741
Conversation
786b70d
to
48549d1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #741 +/- ##
==========================================
+ Coverage 92.30% 92.35% +0.04%
==========================================
Files 91 91
Lines 12417 12450 +33
Branches 12417 12450 +33
==========================================
+ Hits 11462 11498 +36
+ Misses 849 846 -3
Partials 106 106 ☔ View full report in Codecov by Sentry. |
362200c
to
3e11492
Compare
7c561f8
to
e813a31
Compare
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.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/constraint_framework/constant_columns.rs
line 17 at r1 (raw file):
/// Generates a column with a single one at every `2^log_step` positions, and zero elsewhere. // TODO(andrew): Optimize. Is a quotients of two coset_vanishing (use succinct rep for verifier).
Not 100% sure what's better for the verifier.
Suggestion:
// TODO(andrew): Consider optimizing. Is a quotients of two coset_vanishing (use succinct rep for verifier).
crates/prover/src/constraint_framework/constant_columns.rs
line 37 at r1 (raw file):
/// [`CircleDomain`]: crate::core::poly::circle::CircleDomain /// [`Coset`]: crate::core::circle::Coset fn coset_index_to_circle_domain_index(coset_index: usize, log_domain_size: u32) -> usize {
Looks very similar to offset_bit_reversed_circle_domain_index()
. Can we unite?
crates/prover/src/core/backend/simd/column.rs
line 118 at r1 (raw file):
} let length = self.length;
Can we use collect() here as well?
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 249 at r1 (raw file):
) -> ColumnVec<CircleEvaluation<SimdBackend, BaseField, BitReversedOrder>> { let eq_evals = SimdBackend::gen_eq_evals(eval_point, SecureField::one()).into_evals(); let eq_evals_coordinate_columns = eq_evals.into_secure_column().columns;
Might it be better to just keep eq_evals as a secure colum to begin with/
e813a31
to
362a3ef
Compare
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @spapinistarkware)
crates/prover/src/constraint_framework/constant_columns.rs
line 17 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Not 100% sure what's better for the verifier.
Done.
crates/prover/src/constraint_framework/constant_columns.rs
line 37 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Looks very similar to
offset_bit_reversed_circle_domain_index()
. Can we unite?
United with coset_order_to_circle_domain_order_index
crates/prover/src/core/backend/simd/column.rs
line 118 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Can we use collect() here as well?
Don't think it would be appropriate.
Could do self.into_iter<Item=SecureField>
and then collect into SecureColumn but I don't think that's very efficient given the way PackedSecureField is stored. Can't do self.into_iter<Item=PackedSecureField>
because length information could be lost
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 249 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Might it be better to just keep eq_evals as a secure colum to begin with/
Yes. Would require a few changes so added as a TODO for now
af634d6
to
ba7d85c
Compare
0901dcb
to
45efb37
Compare
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.
Reviewed 4 of 7 files at r2, 1 of 2 files at r3, all commit messages.
Reviewable status: 6 of 8 files reviewed, 1 unresolved discussion (waiting on @andrewmilson)
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.
Reviewable status: 6 of 8 files reviewed, 2 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 74 at r3 (raw file):
mask_offsets[1..].copy_from_slice(&variable_step_offsets); let mask_items = eval.next_extension_interaction_mask(TRACE, mask_offsets);
We should be able to do this with just next row offsets. Talk to me.
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.
Reviewed 1 of 7 files at r2.
Reviewable status: 7 of 8 files reviewed, 1 unresolved discussion (waiting on @andrewmilson)
45efb37
to
eed4ce8
Compare
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.
Reviewable status: 6 of 8 files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 74 at r3 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
We should be able to do this with just next row offsets. Talk to me.
Done.
5d385e8
to
134d883
Compare
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.
Reviewable status: 6 of 8 files reviewed, 3 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 13 at r4 (raw file):
#[educe(Debug, Clone, Copy)] pub struct EqEvalsMask<E: EvalAtRow, const N_VARIABLES: usize> { pub curr: E::EF,
Document fields.
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 57 at r4 (raw file):
// Check the initial value on half_coset0 and final value on half_coset1. // Combining these constraints is safe because `is_first` and `is_second` are never // non-zero at the same time on the trace.
Do we really need 2 selectors for each constraint?
We can probably have 1 selector with 2 offsets [0,1] or [0,-1], right?
Do you think it's better this way?
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.
Reviewable status: 6 of 8 files reviewed, 5 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 12 at r4 (raw file):
#[derive(Educe)] #[educe(Debug, Clone, Copy)] pub struct EqEvalsMask<E: EvalAtRow, const N_VARIABLES: usize> {
Suggestion:
MulitlinearEqConstraints
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 12 at r4 (raw file):
#[derive(Educe)] #[educe(Debug, Clone, Copy)] pub struct EqEvalsMask<E: EvalAtRow, const N_VARIABLES: usize> {
/// Evaluates EqEvals constraints on a column.
/// Given a column c(P) defined on a circle domain D,
/// and an mle evalaution point r0, r1, ...
/// evaluates constraints that guarantee:
/// c(D[b0,b1,...]) = eq((b0,b1,...), (r0,r1,...))
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.
Reviewable status: 6 of 8 files reviewed, 6 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 17 at r4 (raw file):
pub is_first: E::F, pub is_second: E::F, pub is_half_coset_step_by_log_size: [Option<CircleDomainStepMask<E>>; N_VARIABLES],
Isn't it prettier to just shift by 1?
Suggestion:
CircleDomainStepMask<E>
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 21 at r4 (raw file):
impl<E: EvalAtRow, const N_VARIABLES: usize> EqEvalsMask<E, N_VARIABLES> { pub fn draw<const EQ_EVALS_TRACE: usize, const SELECTOR_TRACE: usize>(eval: &mut E) -> Self {
I think this is just new
, not draw
.
Also, not need to seperate this frunction from eval, right? They should always be called togther AFAIU.
Just make it a single function. I don't think we even need an auxilliary struct in this case.
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 57 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Do we really need 2 selectors for each constraint?
We can probably have 1 selector with 2 offsets [0,1] or [0,-1], right?
Do you think it's better this way?
Nvm, I see you already do this
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 80 at r4 (raw file):
#[derive(Educe)] #[educe(Debug, Clone, Copy)] pub struct CircleDomainStepMask<E: EvalAtRow> {
Document what this does, and what constant column it needs.
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.
Reviewable status: 6 of 8 files reviewed, 6 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 21 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
I think this is just
new
, notdraw
.Also, not need to seperate this frunction from eval, right? They should always be called togther AFAIU.
Just make it a single function. I don't think we even need an auxilliary struct in this case.
You do need to externalize curr though. But no need for the entire struct.
I suggest calling the function somthing like eval_eq_constraints
and letting it return the value of the eq column, to be used externally. This also makes sure you didn't forget to call the eval, and that you are using the same EvalAtRow, and dont call it twice, etc...
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.
Reviewable status: 6 of 8 files reviewed, 6 unresolved discussions (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 21 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
You do need to externalize curr though. But no need for the entire struct.
I suggest calling the function somthing likeeval_eq_constraints
and letting it return the value of the eq column, to be used externally. This also makes sure you didn't forget to call the eval, and that you are using the same EvalAtRow, and dont call it twice, etc...
Note: If you had instantiated this before ever having EvalAtRow, so that you can hold preprocessed data, this would justify a struct.
298a491
to
6615c41
Compare
134d883
to
b4a93a9
Compare
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.
Reviewable status: 6 of 8 files reviewed, 6 unresolved discussions (waiting on @spapinistarkware)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 12 at r4 (raw file):
#[derive(Educe)] #[educe(Debug, Clone, Copy)] pub struct EqEvalsMask<E: EvalAtRow, const N_VARIABLES: usize> {
Changed to function
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 12 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
/// Evaluates EqEvals constraints on a column. /// Given a column c(P) defined on a circle domain D, /// and an mle evalaution point r0, r1, ... /// evaluates constraints that guarantee: /// c(D[b0,b1,...]) = eq((b0,b1,...), (r0,r1,...))
Done.
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 13 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Document fields.
Removed struct.
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 17 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Isn't it prettier to just shift by 1?
Removed.
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 21 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Note: If you had instantiated this before ever having EvalAtRow, so that you can hold preprocessed data, this would justify a struct.
Thanks
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 80 at r4 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Document what this does, and what constant column it needs.
Removed.
6615c41
to
2335769
Compare
b4a93a9
to
abf86a1
Compare
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.
Reviewed 1 of 2 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @andrewmilson)
crates/prover/src/examples/xor/eq_eval_constraints.rs
line 17 at r5 (raw file):
/// /// See <https://eprint.iacr.org/2023/1284.pdf> (Section 5.1). pub fn eval_eq_constraints<
Very cool
2335769
to
0e7d407
Compare
abf86a1
to
fa8c562
Compare
fa8c562
to
614b466
Compare
This change is