Skip to content
Snippets Groups Projects
Commit 00ae3089 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge branch 'XX-3833/rng' into 'release'

Use the fastRNG instead of rand.Reader

See merge request !198
parents ac5fc84b fe8bcb0b
No related branches found
No related tags found
3 merge requests!233Modify restore to call user-defined bindings callback. Add Sent requests to...,!231Revert "Update store to print changes to the partners list",!198Use the fastRNG instead of rand.Reader
...@@ -11,9 +11,12 @@ package network ...@@ -11,9 +11,12 @@ package network
// and intraclient state are accessible through the context object. // and intraclient state are accessible through the context object.
import ( import (
"crypto/rand"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"math"
"sync/atomic"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces"
...@@ -34,9 +37,6 @@ import ( ...@@ -34,9 +37,6 @@ import (
"gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"math"
"sync/atomic"
"time"
) )
// fakeIdentityRange indicates the range generated between // fakeIdentityRange indicates the range generated between
...@@ -266,10 +266,12 @@ func (m *manager) SetFakeEarliestRound(rnd id.Round) { ...@@ -266,10 +266,12 @@ func (m *manager) SetFakeEarliestRound(rnd id.Round) {
// GetFakeEarliestRound generates a random earliest round for a fake identity. // GetFakeEarliestRound generates a random earliest round for a fake identity.
func (m *manager) GetFakeEarliestRound() id.Round { func (m *manager) GetFakeEarliestRound() id.Round {
b, err := csprng.Generate(8, rand.Reader) rng := m.Rng.GetStream()
b, err := csprng.Generate(8, rng)
if err != nil { if err != nil {
jww.FATAL.Panicf("Could not get random number: %v", err) jww.FATAL.Panicf("Could not get random number: %v", err)
} }
rng.Close()
rangeVal := binary.LittleEndian.Uint64(b) % 800 rangeVal := binary.LittleEndian.Uint64(b) % 800
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment