-
Notifications
You must be signed in to change notification settings - Fork 248
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
Check if our inputs are malleable modulo the prime of the Field #2008
Comments
For honest users, the check when converting Toml inputs into witnesses is probably enough |
What would be the difference between unsigned integers and ordered Fields? Or were you simply suggesting to document that as the reason of why Fields behave as they do? |
unsigned integers usually mean modulo 2^{bit_size} while an ordered field is a set of numbers usually [0,p-1] ie its modulo p |
Spoke with Ethan and next steps would be to check if the following compiles and issue warnings if so: let x : u8 = 300 |
That should pass as the expected behavior is to do a modulo. This is why |
tested this use dep::std;
fn main() {
let x:u8 = 300;
std::println(x);
} with output "0x012c"
[modulo_overflow_test] Circuit witness successfully solved |
Should note that with the
Because 300 does not fit into a u8. For
It was due to the same principal as the u8 example, assuming that the modulus is 7, then 9 does not fit within the valid range for a Fieldtoo |
Compare with #2858 |
Problem
Context
Imagine our prime is 7.
If the users program looks like:
It's expected that if
x = 2
andy = 2
the proof will verify to be true.It is not quite expected that if
x = 9
andy = 2
that the proof will also pass. Noting that 9 mod 7 == 2.Issue
Without applying constraints, we cannot ensure that the inputs lie within the correct range [0,7). This can get extremely expensive because we would essentially need to take in bytes as input and then reconstruct each field in the circuit.
Is it an issue?
Technically this is how
Field
type operates as there is an equivalence relation. Since we don't allow it to done on<
and>
, this can only trip folks up when doing equality. The reason it is only on equality and not on<
and>
is because a Field has no ordering, just equality, so the compiler docs would need to clearly note that we are applying extra constraints on top of the definition of a Field in order to have "ordering". This extra constraint would be choosing a representative for each set, usually this is [0, p).Happy Case
I think a test and documentation around this equality problem would be the best way forward.
Ideally we ask users to avoid using Field wherever possible, but since the proving systems are not fast enough right now, this is a massive performance hit.
Alternatives Considered
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: