Commit Graph

4 Commits

Author SHA1 Message Date
Emmanuel Odeke 8638961f02
common: Rand* warnings about cryptographic unsafety
Lesson articulated by @jaekwon on why we need 80 bits
of entropy at least before we can think of cryptographic
safety. math/rand's seed is a max of 64 bits so can never
be cryptographically secure.

Also added some benchmarks for RandBytes
2017-12-15 22:41:36 -07:00
Emmanuel Odeke cdc7988823
common: use genius simplification of tests from @ebuchman
Massive test simplication for more reliable tests from @ebuchman
2017-12-15 02:14:08 -07:00
Ethan Buchman b5f465b4ec common: use names prng and mrand 2017-12-15 00:23:25 -05:00
Emmanuel Odeke 29471d75cb
common: no more relying on math/rand.DefaultSource
Fixes https://github.com/tendermint/tmlibs/issues/99
Updates https://github.com/tendermint/tendermint/issues/973

Removed usages of math/rand.DefaultSource in favour of our
own source that's seeded with a completely random source
and is safe for use in concurrent in multiple goroutines.
Also extend some functionality that the stdlib exposes such as
* RandPerm
* RandIntn
* RandInt31
* RandInt63

Also added an integration test whose purpose is to be run as
a consistency check to ensure that our results never repeat
hence that our internal PRNG is uniquely seeded each time.
This integration test can be triggered by setting environment variable:
`TENDERMINT_INTEGRATION_TESTS=true`
for example
```shell
TENDERMINT_INTEGRATION_TESTS=true go test
```
2017-12-14 00:18:30 -07:00