-
Notifications
You must be signed in to change notification settings - Fork 265
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 additional PRNG #1774
Add additional PRNG #1774
Conversation
d152522
to
dd903c4
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1774 +/- ##
==========================================
+ Coverage 89.27% 89.38% +0.10%
==========================================
Files 143 145 +2
Lines 10948 11030 +82
Branches 480 466 -14
==========================================
+ Hits 9774 9859 +85
+ Misses 1174 1171 -3
|
99da5a4
to
1c31cf7
Compare
35037f1
to
0df44d9
Compare
eclair-core/src/main/scala/fr/acinq/eclair/crypto/WeakEntropyPool.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/crypto/keymanager/LocalChannelKeyManager.scala
Outdated
Show resolved
Hide resolved
In case of catastrophic failures of the `SecureRandom` instance, we add a secondary randomness source that we mix into the random stream. This is a somewhat weak random source and should not be used on its own, but it doesn't hurt to xor it with the output of `SecureRandom`. We use an actor that listens to events in the system and inject them in our weak pseudo-RNG.
These functions have side-effects, it was incorrect and misleading to expose them without parenthesis.
1e9f0ce
to
1e1037f
Compare
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.
According to this, XORing two pseudorandom data sources cannot reduce randomness, as long as the two sources are unrelated to each other. This is the case here because we know exactly how the WeakRandom
generator works.
Let's wait for a full review from @sstone before merging. |
ChaCha20 is designed to allow encrypting directly inside the plaintext array to avoid allocating another array for the ciphertext. We add a test case to ensure this is working as expected.
In case of catastrophic failures of the
SecureRandom
instance, we add a secondary randomness source that we mix into the random stream.This is a somewhat weak random source and should not be used on its own, but it doesn't hurt to xor it with the output of
SecureRandom
.The second commit should be reviewed independently: it simply adds parenthesis to functions that generate random things, since these have side-effects. It's trivial but painful to review since it touches a lot of test files.
NB: this feature make a lot of sense in https://github.com/acinq/lightning-kmp as well since mobile platforms may have more common randomness failures.