From 2caa4a6e7cd2bd6f053fd0799abf8775f6a5178a Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Tue, 12 Jan 2021 18:40:06 -0500 Subject: lib: update randomBytes Use randomInt to get the random byte array length. --- lib/oracle.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/oracle.go b/lib/oracle.go index 6a229dc..1c548ff 100644 --- a/lib/oracle.go +++ b/lib/oracle.go @@ -84,20 +84,8 @@ func randomInt(min, max int64) int64 { // Randomly generates `min` to `max` bytes. func randomBytes(min, max int64) []byte { - var rn *big.Int - var err error - for { - rn, err = rand.Int(rand.Reader, big.NewInt(max+1)) - if err != nil { - panic(err) - } - if rn.Int64() >= min { - break - } - } - - bs := make([]byte, rn.Int64()) - _, err = rand.Read(bs) + bs := make([]byte, randomInt(min, max)) + _, err := rand.Read(bs) if err != nil { panic(err) } -- cgit v1.2.3