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

fix: ensure witness size is power of two #338

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

Conversation

DeVikingMark
Copy link

Fixes #287

Added check to ensure witness size is power of two in CRR1CSProof::prove() function to prevent potential index out of bounds error when reading from empty vector.

Changes made:

  • Added assertion to check if witness size is power of two
  • Added descriptive error message for better debugging

This prevents the issue where reading index of zero from an empty vector could occur if the witness size is not a power of two.

@sjudson
Copy link
Contributor

sjudson commented Jan 6, 2025

@DeVikingMark thanks for taking a pass at this. Looks like tests are failing at the moment, however.

@DeVikingMark
Copy link
Author

DeVikingMark commented Jan 20, 2025

@DeVikingMark thanks for taking a pass at this. Looks like tests are failing at the moment, however.

by chance, do these changes seem alright to you?

Copy link
Contributor

@sjudson sjudson left a comment

Choose a reason for hiding this comment

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

Thanks for this, looks good to me.

@sjudson
Copy link
Contributor

sjudson commented Jan 21, 2025

@DeVikingMark looks like it needs some formatting + clippy fixes.

Copy link
Contributor

@sjudson sjudson left a comment

Choose a reason for hiding this comment

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

Withdrawing acceptance till pending tests are fixed, but overall design still looks good.

@sjudson
Copy link
Contributor

sjudson commented Jan 23, 2025

@DeVikingMark what is the reason for removing an existing test?

Also, please run cargo fmt and cargo clippy --all-targets --all-features, since those lints keep failing.

sjudson pushed a commit that referenced this pull request Feb 5, 2025
Summary:

Originally, the MemAccessSize value is `n - 1` for short masking code, turn out we didn't use, let's revert it back to original size.

Test Plan:

Co-authored-by: duc-nx <>
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.

[BUG]: Witness size to be a power of 2^n isn't checked in Spartan/crr1csproof.rs
2 participants