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

crypto: add random big integer generation #22266

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

einar-hjortdal
Copy link
Contributor

Addresses #22206

vlib/crypto/rand/utils.v Outdated Show resolved Hide resolved
vlib/crypto/rand/utils.v Outdated Show resolved Hide resolved
vlib/crypto/rand/utils.v Outdated Show resolved Hide resolved
Comment on lines 68 to 71
if len == 0 {
// max must be 0
return max
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems weird. Why return a definite number, from a function that is said to return a random one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a little more explanation in the comment.
If the user-given max is 1, the only valid integer in [0, 1) is 0. So 0 is returned early.
I think allowing users to give 1 as max is ok.

vlib/crypto/rand/utils.v Outdated Show resolved Hide resolved
@spytheman
Copy link
Member

The vab failure is unrelated, and now fixed on master.
The other CI failure is sporadic (flaky test), and not related to this PR.

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 this pull request may close these issues.

2 participants