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 posqltime #14

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open

Refactor posqltime #14

wants to merge 48 commits into from

Conversation

varshith257
Copy link
Owner

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

What changes are included in this PR?

Are these changes tested?

@varshith257 varshith257 force-pushed the refactor-posqltime branch 2 times, most recently from b667064 to eb75d22 Compare January 4, 2025 11:52
@varshith257 varshith257 force-pushed the refactor-posqltime branch 7 times, most recently from b9cd336 to 04a1c60 Compare January 13, 2025 18:31
@varshith257 varshith257 force-pushed the refactor-posqltime branch 3 times, most recently from 7621c97 to 18a1d81 Compare January 14, 2025 02:23
JayWhite2357 and others added 10 commits January 14, 2025 06:58
…ipt_bytes` (spaceandtimelabs#471)

# Rationale for this change

We will want to serialize commitments in a manner compatible with the
transcript. This facilitates doing this without duplicating code.

# What changes are included in this PR?

`Commitment::append_to_transcript` is removed and `to_transcript_bytes`
is added instead. Usage is replaced as well.

# Are these changes tested?

Yes.
# Rationale for this change

The current mechanism for drawing a challenge is a bit opaque. This
simplifies it.

# What changes are included in this PR?

When drawing a challenge from the transcript, it is 32 bytes long.
Instead of using `[u64; 4]` to coerce it into a `Scalar`, it is more
straightforward to simply drop the first few bits. This can be
accomplished by masking the challenged by a `CHALLENGE_MASK` before
converting to a `Scalar`.

Additionally, this PR updates the `Scalar` implementations so that we
have a blanket implementation of `impl<T> Scalar for MontScalar<T>`.
This removes the need to manually figure out the constants for each
Scalar type.

# Are these changes tested?

Yes.
spaceandtimelabs#476)

# Rationale for this change

The source of the data/commitments for referenced columns is different
from final round mles. They are also handle very differently. So, they
should be separated in the proof as well.

# What changes are included in this PR?

See rationale and title.

# Are these changes tested?

Yes, by existing tests.
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 reviewed and merged:
  - [x] spaceandtimelabs#417
# Rationale for this change
The membership check gadget is a crucial component of joins. Hence we
need to add it.
<!--
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 spaceandtimelabs#345.

Since we added `HashJoinExec` in spaceandtimelabs#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 membership check gadget and a related test.
<!--
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.
intls and others added 12 commits January 15, 2025 19:31
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 joins it is necessary to have not only one evaluations but also
evaluations of rho = (0, 1, 2, \cdots, n-1) vectors. Hence we need to
add them to our proofs.
<!--
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 spaceandtimelabs#345.

Since we added `HashJoinExec` in spaceandtimelabs#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?
- an algorithm to compute rho evaluations
<!--
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.
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.
- [ ] I have run the ci check script with `source
scripts/run_ci_checks.sh`.

# Rationale for this change

Hope helps! 


Since we added `HashJoinExec` in spaceandtimelabs#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?

While reviewing the docs found errors in the comments to the code.
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.
-->
iajoiner and others added 13 commits January 16, 2025 13:46
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.
- [ ] I have run the ci check script with `source
scripts/run_ci_checks.sh`.
…erificationBuilder` (spaceandtimelabs#484)

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
- [ ] 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.
- [ ] I have run the ci check script with `source
scripts/run_ci_checks.sh`.

# Rationale for this change
These changes are beneficial since we shouldn't panic in
`VerificationBuilder`.
<!--
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 spaceandtimelabs#345.

Since we added `HashJoinExec` in spaceandtimelabs#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 title.
<!--
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.
-->
Existing tests do pass.
# Rationale for this change

Currently, it is possible to argue the correct ranges of scalars up to
the word value size, but anything below or beyond this value (currently
256 for byte sized words) will fail to verify. This PR expands range
check on a scalar column to arbitrary lengths.

# What changes are included in this PR?

- [x] arbitrary lengths beyond maximum word value
- [x] arbitrary lengths below maximum word value
- benches were carried out in criterion and jaeger
- refactored inner functions to make the loops more readable, will move
back to idiomatic representations before marking this ready for merge


# Are these changes tested?

- [x] test can range check up to 2^248 boundary
- [x] test cannot range check past 2^ 248 boundary
- [x] test cannot range check below 0
- [x] test can range check below the maximum word size value
- [x] range check with dory
- [x] range check with ipa - currently failing as certain column lengths
for unknown reason, see spaceandtimelabs#464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants