-
Notifications
You must be signed in to change notification settings - Fork 219
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(std_lib)!: modulus bits and modulus bytes methods #697
Conversation
I think this could be simplified, once we have big integers, into a simple |
I had thought of something similar and mentioned it in the issue #549. Are you worried that users might use these modulus methods and when we introduce BigInt and change the methods they would have to update their circuits?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind the byte array being big endian? Since to_le_bytes exists I think it'd be easier for users if everything was little endian (or the reverse).
Yes, but I agree it will be either a small change for them or we can make it transparent easily. |
I was mainly trying to follow the discussion in the issue. We also currently have an issue up in acvm about updating to both |
@guipublic @jfecher @kevaundray What do we think about also moving these methods to a |
I'd be for moving it to |
So once we have a native BigInt we can make a new builtin simply for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is std::array::len
still failing on the returned arrays of modulus_array_literal?
|
I renamed all the functions to have the endian specification trailing the function name (ex. I held off on implementing |
mentioned naming these to @kevaundray the other day. It seems rust is using |
I switched back to use |
* master: Rename methods that use `conditionalize` to be more descriptive (#739) feat(noir)!: Returned values are no longer required by the prover (#731) chore: explicit versions for dependencies (#727) chore: readability improvements (#726) feat(nargo): include short git commit in cli version output (#721) Remove print to console for named proofs in `nargo prove` (#718) chore: clean up serde-related dependencies (#722) Handle out-of-bound errors in CSE (#471) (#673) Remove unused dependencies and only use workspace inheritance on shared deps (#671) feat(std_lib)!: modulus bits/bytes methods, and to_bits -> to_le_bits (#697) Implement numeric generics (#620) Review some TODO in SSA (#698) Replace `toml_map_to_field` and `toml_remap` with traits to map between `InputValue`s and `TomlTypes` (#677) Apply witness visibility on a parameter level rather than witness level (#712)
Related issue(s)
Resolves #549
Description
Adds two builtin functions,
modulus_bits
andmodulus_be_byte_array
.modulus_bits
returns the number of bits in the modulus whilemodulus_be_byte_array
returns the modulus as a byte array.Summary of changes
We can evaluate the modulus at callsite so I simply added some logic to
try_evaluate_call
(where we evaluate the arraylen builtin).I am considering to instead change
modulus_bits
to return a bit array of the modulus. Then if a user wants the number of bits in the modulus they can just take the array len of this bit array.Dependency additions / changes
Test additions / changes
I added a test that calls both methods and tests their outputs.
Checklist
cargo fmt
with default settings.Additional context
Reference issue for some further discussion about the best array types for returning the modulus