-
Notifications
You must be signed in to change notification settings - Fork 20
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
Inject uniformly distributed randomness into Scalar::random
#129
Comments
Resolves: #129 Co-authored-by: Victor Lopez <vhrlopes@gmail.com>
After extensive discussions we decided to not change the random scalar generation because it was deemed secure enough for our purposed: We will use this paper to determine whether the current implementation of the random scalar implementation as done in the In the current implementation of For
and
To check whether the above approach is secure, we do the following: For
This leads to:
and
Now we can check whether:
This clearly holds true, which means that we fall in the first conversion of the paper above, and can safely sample an element from the field over This concludes that we don't need to make any adjustments to the current implementation of random scalar generation. |
Summary
The current
random
method for the bls scalar,implemented as part of theField
trait, is not uniformly distributed: because we 'wrap' the scalar at the modulus some scalars in the field are hit more often than others.We want to implement uniformly distributed randomness (by discarding invalid scalars) but face some complications.
Scalar::random()
as part of theField
trait) may not be changed so we don't break backwards compatibility (we removed code that we don't need but left everything else like it is in the upstream crate)uni_random()
Possible solution design or implementation
fill_bytes
so that only canonical scalars are generated.Field
trait implementation from 'src/scalar.rs' and implement the trait in 'src/scalar/dusk/rs'. That way we can change the implementation ofrandom()
as we see fitAdditional context
The same needs to be done for jubjub scalars
The text was updated successfully, but these errors were encountered: