-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow
FirstRoundBuilder
to produce MLEs (#417)
Please be sure to look over the pull request guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr. # Please go through the following checklist - [x] The PR title and commit messages adhere to guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md. In particular `!` is used if and only if at least one breaking change has been introduced. - [x] I have run the ci check script with `source scripts/run_ci_checks.sh`. # Rationale for this change For range check and joins we need to have pre-challenge committing of columns. As a result we need to add such functionalities to `FirstRoundBuilder`. <!-- Why are you proposing this change? If this is already explained clearly in the linked issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. Example: Add `NestedLoopJoinExec`. Closes #345. Since we added `HashJoinExec` in #323 it has been possible to do provable inner joins. However performance is not satisfactory in some cases. Hence we need to fix the problem by implement `NestedLoopJoinExec` and speed up the code for `HashJoinExec`. --> # What changes are included in this PR? See above. <!-- There is no need to duplicate the description in the ticket here but it is sometimes worth providing a summary of the individual changes in this PR. Example: - Add `NestedLoopJoinExec`. - Speed up `HashJoinExec`. - Route joins to `NestedLoopJoinExec` if the outer input is sufficiently small. --> # Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? Example: Yes. --> Will be.
- Loading branch information
Showing
28 changed files
with
532 additions
and
110 deletions.
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
75 changes: 75 additions & 0 deletions
75
crates/proof-of-sql/src/sql/proof/first_round_builder_test.rs
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use super::FirstRoundBuilder; | ||
use crate::base::{ | ||
commitment::{Commitment, CommittableColumn}, | ||
scalar::Curve25519Scalar, | ||
}; | ||
use curve25519_dalek::RistrettoPoint; | ||
|
||
#[test] | ||
fn we_can_compute_commitments_for_intermediate_mles_using_a_zero_offset() { | ||
let mle1 = [1, 2]; | ||
let mle2 = [10i64, 20]; | ||
let mut builder = FirstRoundBuilder::<Curve25519Scalar>::new(); | ||
builder.produce_intermediate_mle(&mle1[..]); | ||
builder.produce_intermediate_mle(&mle2[..]); | ||
let offset_generators = 0_usize; | ||
let commitments: Vec<RistrettoPoint> = builder.commit_intermediate_mles(offset_generators, &()); | ||
let expected_commitments: Vec<RistrettoPoint> = RistrettoPoint::compute_commitments( | ||
&[ | ||
CommittableColumn::from(&mle1[..]), | ||
CommittableColumn::from(&mle2[..]), | ||
], | ||
offset_generators, | ||
&(), | ||
); | ||
assert_eq!(commitments, expected_commitments,); | ||
} | ||
|
||
#[test] | ||
fn we_can_compute_commitments_for_intermediate_mles_using_a_non_zero_offset() { | ||
let mle1 = [1, 2]; | ||
let mle2 = [10i64, 20]; | ||
let mut builder = FirstRoundBuilder::<Curve25519Scalar>::new(); | ||
builder.produce_intermediate_mle(&mle1[..]); | ||
builder.produce_intermediate_mle(&mle2[..]); | ||
let offset_generators = 123_usize; | ||
let commitments: Vec<RistrettoPoint> = builder.commit_intermediate_mles(offset_generators, &()); | ||
let expected_commitments: Vec<RistrettoPoint> = RistrettoPoint::compute_commitments( | ||
&[ | ||
CommittableColumn::from(&mle1[..]), | ||
CommittableColumn::from(&mle2[..]), | ||
], | ||
offset_generators, | ||
&(), | ||
); | ||
assert_eq!(commitments, expected_commitments,); | ||
} | ||
|
||
#[test] | ||
fn we_can_evaluate_pcs_proof_mles() { | ||
let mle1 = [1, 2]; | ||
let mle2 = [10i64, 20]; | ||
let mut builder = FirstRoundBuilder::<Curve25519Scalar>::new(); | ||
builder.produce_intermediate_mle(&mle1[..]); | ||
builder.produce_intermediate_mle(&mle2[..]); | ||
let evaluation_vec = [ | ||
Curve25519Scalar::from(100u64), | ||
Curve25519Scalar::from(10u64), | ||
]; | ||
let evals = builder.evaluate_pcs_proof_mles(&evaluation_vec); | ||
let expected_evals = [ | ||
Curve25519Scalar::from(120u64), | ||
Curve25519Scalar::from(1200u64), | ||
]; | ||
assert_eq!(evals, expected_evals); | ||
} | ||
|
||
#[test] | ||
fn we_can_add_post_result_challenges() { | ||
let mut builder = FirstRoundBuilder::<Curve25519Scalar>::new(); | ||
assert_eq!(builder.num_post_result_challenges(), 0); | ||
builder.request_post_result_challenges(1); | ||
assert_eq!(builder.num_post_result_challenges(), 1); | ||
builder.request_post_result_challenges(2); | ||
assert_eq!(builder.num_post_result_challenges(), 3); | ||
} |
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
Oops, something went wrong.