Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
fix: switch from math/rand to crypto/rand (#270)
Browse files Browse the repository at this point in the history
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat authored Jun 29, 2022
1 parent 26bccf9 commit ce8776c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ SPDX-License-Identifier: Apache-2.0
package rollingcounter

import (
"math/rand"
"crypto/rand"
"math/big"
"sync/atomic"

"github.com/hyperledger/aries-framework-go/pkg/common/log"
Expand Down Expand Up @@ -42,7 +43,12 @@ func (c *Counter) Next(n int) int {
i := int(current)
if i == -1 {
// Choose a random index the first time
i = rand.Intn(n) //nolint: gosec
result, err := rand.Int(rand.Reader, big.NewInt(int64(n)))
if err != nil {
panic(err.Error())
}

i = int(result.Int64())
} else {
i++
if i >= n {
Expand Down

0 comments on commit ce8776c

Please sign in to comment.