fix: allow usage of decimal string encoding for fields larger than a i128
#2547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem*
Resolves #2545
Resolves partly #2456
Summary*
When parsing fields from strings, we're currently converting the string into an
i128
temporarily if it's a decimal representation. This limits the size of values which can be passed in as a decimal string compared to hex strings.We now instead parse using a
BigUint
to ensure that we can handle all inputs.Documentation
This PR requires documentation updates when merged.
Additional Context
Note that
FieldElement
has atry_from_str
implementation but as it returns anOption<FieldElement>
rather than aResult<FieldElement, Err>
, it's then not suitable for dealing with user input.https://github.com/noir-lang/acvm/blob/5ad18bf8b365b57ba4c6f84004b5178e54562e7e/acir_field/src/generic_ark.rs#L204-L211
PR Checklist*
cargo fmt
on default settings.