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

Split FieldError::ModulusOverflow variant #856

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

divergentdave
Copy link
Contributor

The FieldError::ModulusOverflow variant is currently used in three situations:

  1. try_from_bytes(): This is the original use of this error, and it directly matches the existing error message. It decodes an integer from a byte slice, compares the integer against the modulus, and returns a field element.
  2. valid_integer_try_from(): This converts from one integer type to another, and additionally compares against the field modulus.
  3. Bit vector encoding/decoding helpers: These compare the requested bit vector length against the bit length of the modulus.

Using ModulusOverflow in the bit vector case is a misnomer, as we're checking a different condition. Additionally, in valid_integer_try_from(), no byte slice is involved. This PR introduces a dedicated error variant for the bit vector helper, and rewrites the existing message for ModulusOverflow, so that error messages better align with their causes.

@divergentdave divergentdave requested a review from a team as a code owner November 29, 2023 20:12
@divergentdave divergentdave merged commit 734039d into main Dec 1, 2023
6 checks passed
@divergentdave divergentdave deleted the david/split-modulusoverflow branch December 1, 2023 21:42
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.

2 participants