-
Notifications
You must be signed in to change notification settings - Fork 5
Setting the random seed every time is not a good idea #10
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
Conversation
Yes, would be better to init |
Calling it at the beginning of the module may change the user's fixed seed, so it might be a better choice to let users call it themselves. |
I'm afraid that's not a good way to handle this, which require the user to be familiar with the library's implementation. :) |
Indeed, a better approach is to use a separate random generator in each instance so that it can independently set a fixed seed or a random one. However, Lua's built-in random generator is global, and implicitly setting the random seed can cause many problems. |
That's a bit of an overstatement in It shouldn't cause any issue as the random number seeds are not duplicated in such a scenario. |
It should be common sense to set the seed before all random operations. Setting it implicitly when loading the module does not simplify usage and introduces global side effects. I don't think this is a good way. |
Sounds fair, let's move it to a separate function and add test cases. |
Ok, I should be able to do it tomorrow. :) |
|
Yep, I will fix it. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Remove
math.randomseed
call fromtotp_new_key
function.