Commit Graph

11 Commits

Author SHA1 Message Date
Thomas Corbière 3375dac049 add Float64() and RandFloat64(). 2018-04-03 14:09:50 +02:00
Jae Kwon 3412587036 Fix race condition in random.go 2018-03-18 01:50:15 +01:00
Jae Kwon 90cd89eab0
Unexpose r.rand (#167) 2018-03-17 05:18:22 -07:00
Jae Kwon 6d61ca3bb5 New -> NewRand 2018-03-17 12:34:23 +01:00
Jae Kwon 536c27de8e
common/random.go supports seeding and *Rand (#121)
* common/random.go supports seeding and *Rand
* Ensure determinism
2018-03-17 04:28:53 -07:00
Ethan Buchman a25ed5ba1b cmn: fix race condition in prng 2017-12-21 10:02:25 -05:00
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
Ethan Buchman 356657a37b move all files to common/ to begin repo merge 2017-04-18 16:33:22 -04:00