Skip to content
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!: generalize one eval to arbitrary lengths #381

Merged
merged 5 commits into from
Dec 2, 2024
Merged

Conversation

iajoiner
Copy link
Contributor

@iajoiner iajoiner commented Nov 19, 2024

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

Rationale for this change

When ProofPlans compose it makes no sense to have table_length in VerificationBuilder. Instead it becomes necessary to record each and every instance of length used for one_eval and pass the info to the verifier.

What changes are included in this PR?

  • remove VerificationBuilder::table_length
  • generalize one eval from input_length and output_length to arbitrary lengths
  • add singleton_one_evaluation to SumcheckMleEvaluations
  • add consumption of the lengths in VerificationBuilder
  • add TableEvaluation
  • add one_eval as an arg to ProofExpr::verifier_evaluate
  • return TableEvaluation in ProofPlan::verifier_evaluate
  • return (Table<'a, S>, Vec<usize>) in ProofPlan::result_evaluate to return one eval lengths
  • remove range_length logic from FirstRoundBuilder as ProofPlan::result_evaluate already tracks potentially large output lengths in intermediate tables

Are these changes tested?

Yes.

@iajoiner iajoiner force-pushed the refactor/lengths branch 2 times, most recently from 9d87859 to 2eb1d15 Compare November 21, 2024 02:46
@iajoiner iajoiner enabled auto-merge November 21, 2024 02:46
@iajoiner iajoiner force-pushed the refactor/lengths branch 5 times, most recently from 160a15a to 27218fe Compare November 24, 2024 06:49
@iajoiner iajoiner force-pushed the refactor/lengths branch 2 times, most recently from 98b06ed to a85b1b5 Compare November 26, 2024 14:28
@iajoiner iajoiner mentioned this pull request Nov 26, 2024
5 tasks
@iajoiner iajoiner force-pushed the refactor/lengths branch 3 times, most recently from 5ff0e59 to 35442f3 Compare November 26, 2024 18:27
@iajoiner iajoiner force-pushed the refactor/lengths branch 3 times, most recently from 56030f1 to 41f7e9b Compare November 26, 2024 19:00
@@ -282,6 +298,7 @@ pub(super) fn prove_filter<'a, S: Scalar + 'a>(
n: usize,
m: usize,
) {
builder.push_one_evaluation_length(m);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside the prove_filter, but the corresponding consume is outside the verify_filter. Functionally it is correct, but we should keep the prove and verify mirrored. Either move them both in, or move them both out.

@@ -82,9 +82,9 @@ pub fn prover_evaluate_sign<'a, S: Scalar>(
builder: &mut FinalRoundBuilder<'a, S>,
alloc: &'a Bump,
expr: &'a [S],
table_length: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should just use expr.len().

@@ -178,6 +180,7 @@ impl<CP: CommitmentEvaluationProof> QueryProof<CP> {

let proof = Self {
bit_distributions: builder.bit_distributions().to_vec(),
one_evaluation_lengths: builder.one_evaluation_lengths().to_vec(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lengths need to be passed to make_transcript in order for the proof to be secure.

Comment on lines 289 to 291
.chain(self.one_evaluation_lengths.clone().iter())
.copied()
.collect::<Vec<_>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: there is a lot of clone/copy/collect here. At least some of them can be avoided.

@iajoiner iajoiner force-pushed the refactor/lengths branch 2 times, most recently from 636fe8d to 61ff4b5 Compare December 2, 2024 18:05
@iajoiner iajoiner merged commit a10ff3b into main Dec 2, 2024
11 checks passed
Copy link

github-actions bot commented Dec 2, 2024

🎉 This PR is included in version 0.51.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@iajoiner iajoiner deleted the refactor/lengths branch December 3, 2024 17:20
iajoiner added a commit that referenced this pull request Dec 4, 2024
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`.
- The following upstream PRs have been merged:
  - [x] #381
  - [x] #401
  - [x] #404

# Rationale for this change
This PR replaces #121 and is designed to test whether our `ProofPlan`s
are truly composable now.
<!--
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?
- add `SliceExec`.
<!--
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.
-->
Yes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants