-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
coin selection code uses unseeded rand() call #1057
Comments
Probably. It is the only place in the source where rand() is used. |
I see it in commented code in main.cpp too:
I wonder if perhaps it's deliberate, because the wallet rand() code is in a tight loop and we don't want to exhaust our entropy source. |
That loop execute a great many times— a proper cryptographically secure RNG is probably going to be noticeably slow here. If it is, then would anyone object to using a fast PRNG seeded by RandBytes at the start of the function? In general I don't think there is a big privacy concern here— even knowing the random sequence completely shouldn't matter unless you also know the inputs under consideration. |
@gmaxwell also, rand() is not thread-safe according to its man page, using rand_r(*seed) is recommended in that case is as it has explicit state. If there is no privacy concern here, a simple solution would be using rand_r with the state (just one int) generated at the beginning of the function with GetRandInt(). |
We don't use rand() anymore but our own insecure_rand() for non-security-critical randomness that does get seeded. Closing this. |
9b8955a Fix AA_EnableHighDpiScaling warning (Akshay) Pull request description: Fixes the following warning `Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.` Tested on macOS 10.14.6 ACKs for top commit: furszy: ACK 9b8955a random-zebra: utACK 9b8955a and merging... Tree-SHA512: f65b10f570bd642da9428e634c89bfe6303ccbeb1f3995c85993845c86a321dccb1f50cdd39832e4c2e910942f0b284944bd88cd181cf7a15fc46279e30e22b3
In the code which selects which coins to use, the following appears:
but rand() is never seeded.
Should we use GetRandInt(2) instead to get unpredictable results?
The text was updated successfully, but these errors were encountered: