From 98795274e861981276b5f4c1cdb45535ba288f7d Mon Sep 17 00:00:00 2001 From: David Florness Date: Sun, 11 Oct 2020 22:40:03 -0400 Subject: [PATCH] Fix RandomBigInt --- poly.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poly.go b/poly.go index 855072c..c05505a 100644 --- a/poly.go +++ b/poly.go @@ -18,10 +18,10 @@ func RandomBigInt(numBytes uint, allowAllZeros bool) (*big.Int, error) { return nil, err } bi := new(big.Int).SetBytes(randBytes) - if bi.Cmp(big.NewInt(0)) == 0 { + if !allowAllZeros && bi.Cmp(big.NewInt(0)) == 0 { return RandomBigInt(numBytes, allowAllZeros) } - return bi.SetBytes(randBytes), nil + return bi, nil } // creates a random polynomial of the given degree, uses at least `entropy' bits -- 2.38.4