Documentation
¶
Overview ¶
Package rand provides cryptographically secure random number generation
Index ¶
- Variables
- func GenerateNonce(length int) ([]byte, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomInt(min, max int) (int, error)
- func GenerateRandomPrime(bits int) (*big.Int, error)
- func GenerateRandomScalar(max *big.Int) (*big.Int, error)
- func Shuffle(n int, swap func(i, j int)) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidLength is returned when requested length is invalid ErrInvalidLength = errors.New("invalid length: must be positive") // ErrNilMax is returned when max parameter is nil ErrNilMax = errors.New("max cannot be nil") // ErrInvalidMax is returned when max is not positive ErrInvalidMax = errors.New("max must be positive") // ErrInvalidRange is returned when range parameters are invalid ErrInvalidRange = errors.New("invalid range: min must be less than max") // ErrInvalidBitSize is returned when bit size is too small ErrInvalidBitSize = errors.New("bit size must be at least 2") )
View Source
var Reader io.Reader = rand.Reader
Reader is the default cryptographically secure random number generator
Functions ¶
func GenerateNonce ¶
GenerateNonce generates a cryptographically secure nonce of specified length
func GenerateRandomBytes ¶
GenerateRandomBytes generates n cryptographically secure random bytes
func GenerateRandomInt ¶
GenerateRandomInt generates a random integer in range [min, max)
func GenerateRandomPrime ¶
GenerateRandomPrime generates a random prime of the specified bit size
func GenerateRandomScalar ¶
GenerateRandomScalar generates a random scalar in range [1, max) This is cryptographically secure and uniform
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.