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

feat: range check arbitrary size columns #473

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

Conversation

Dustin-Ray
Copy link
Contributor

@Dustin-Ray Dustin-Ray commented Jan 13, 2025

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?

  • arbitrary lengths beyond maximum word value
  • 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?

@Dustin-Ray Dustin-Ray requested a review from iajoiner January 13, 2025 23:11
@@ -5,6 +5,7 @@ use bitwise_verification::{verify_constant_abs_decomposition, verify_constant_si
mod bitwise_verification_test;
mod sign_expr;
pub(crate) use sign_expr::{prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign};
#[allow(clippy::needless_range_loop)] // keep the loop for readability for now, refactor later
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change this back immediately in the next PR, this was super important to keep for now so that we can understand the loops in the range check functions

@@ -137,8 +146,28 @@ mod tests {
}

#[test]
fn we_can_prove_a_range_check_with_range_0_to_256() {
let data = owned_table([scalar("a", 0..256)]);
#[allow(clippy::cast_sign_loss)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is added because the range used to index the scalars while creating the owned table can be negative but here it doesnt matter because its testing positive ranges only and we cant create a Scalar from but Uints

@Dustin-Ray Dustin-Ray changed the title Feat/arbitrary size columns range check feat: range check arbitrary size columns Jan 13, 2025
@Dustin-Ray Dustin-Ray marked this pull request as ready for review January 13, 2025 23:20
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.

1 participant