-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add trait which validates circuit inputs / unconstrained function return values #4218
Comments
As an extension of creating the first admonition with this Issue, we might want to set an example with U128 given it's in the stdlib. Setting an example in terms of:
|
To take that a step further, we may want to implement an For This would make it much easier for users to consistently enforce that these checks are performed. |
As a workaround, I added input validation to nodash: #[nodash::validate_inputs]
fn main(...) {
...
} |
See note on #4217
We should ensure that the documentation explicitly calls out the need for users to add these constraints themselves.
To take that a step further, we may want to implement an IsValidInput trait which defined the constraints to be added to a type when it's an input to the circuit (either as an argument to main or as a return value from an unconstrained function). We'd then call this trait implementation whenever we receive this type from outside of the circuit.
For U128 we would range check the two limbs. For BoundedVec we'd assert that the length was consistent with the underlying array, etc.
This would make it much easier for users to consistently enforce that these checks are performed.
The text was updated successfully, but these errors were encountered: