-
Notifications
You must be signed in to change notification settings - Fork 12
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
change implementation of dusks Fr::random()
function to be uniformly distributed
#121
Comments
We want to avoid having two different implementations of the random scalar generation, which rules out the above proposal. Instead we should mimic the bls library as implemented in dusk-network/bls12_381#129 |
Fr::random()
function to be uniformly distributed (like in BlsScalar::uni_random()
Fr::random()
function to be uniformly distributed
Resolves: #121 Co-authored-by: Victor Lopez <vhrlopes@gmail.com>
Resolves: #121 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 purpose: 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 implementation of
Fr::random()
in thedusk
module generates a random array of 64 bytes and wraps them around to fit aFr
. This means that some of the values are hit more often than others. To ensure a uniform distribution, we can randomly generate a bit-pattern of 251 bits until a validFr
representation is found.This random scalar generation is not constant time but still as long as the underlying random number generator is functioning as it should, this is no problem.
Relevant Context
bls12_831#124
Possible Solution
The text was updated successfully, but these errors were encountered: