Skip to content
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 a random scalar generation that is uniformly distributed #125

Closed
moCello opened this issue Oct 23, 2023 · 0 comments · Fixed by #126
Closed

Add a random scalar generation that is uniformly distributed #125

moCello opened this issue Oct 23, 2023 · 0 comments · Fixed by #126

Comments

@moCello
Copy link
Member

moCello commented Oct 23, 2023

Summary

The current implementation of a random scalar wraps a randomly generated bit-field around the modulus to ensure the scalar is valid. This approach makes us hit some scalars more than others.
Another approach would be to zero out the highest two bits but that in turn results in missing some scalars entirely.
Ideally we want to have a random scalar generation that is uniformly distributed.

Possible Solution

Use rejection sampling. This makes the random scalar generation not constant time but that shouldn't be a problem since no information on the scalar can be gained by analyzing the time it took to generate it.

moCello added a commit that referenced this issue Oct 23, 2023
moCello added a commit that referenced this issue Oct 23, 2023
moCello added a commit that referenced this issue Oct 23, 2023
moCello added a commit that referenced this issue Oct 23, 2023
moCello added a commit that referenced this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant