summaryrefslogtreecommitdiff
path: root/csrand
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-28 04:22:36 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-28 04:22:36 +0000
commit9fe9959c76c96ec3284f43c692cbb099230dcb73 (patch)
treeac51a41928f56e94a51f686bcb4cba9dbe2ef7b5 /csrand
parentbd2bef2ead3e535d64a233fa1a772fee9041519a (diff)
Change the weighted distribution algorithm be uniform.
The old way was biasted towards the earlier values. Thanks to asn for pointing this out and suggesting an alternative. As an additional tweak, do not reuse the drbg seed when calculating the IAT distribution, but instead run the seed through SHA256 first, for extra tinfoil goodness.
Diffstat (limited to 'csrand')
-rw-r--r--csrand/csrand.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/csrand/csrand.go b/csrand/csrand.go
index 721fb1e..a3299aa 100644
--- a/csrand/csrand.go
+++ b/csrand/csrand.go
@@ -68,7 +68,12 @@ func (r csRandSource) Seed(seed int64) {
// No-op.
}
-// Float64 returns, as a float 64, a pesudo random number in [0.0,1.0).
+// Int63n returns, as a int64, a pseudo random number in [0, n).
+func Int63n(n int64) int64 {
+ return CsRand.Int63n(n)
+}
+
+// Float64 returns, as a float64, a pesudo random number in [0.0,1.0).
func Float64() float64 {
return CsRand.Float64()
}