rand

package
v0.0.0-...-026ee7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufPRGReader

type BufPRGReader struct {
	mrand.Source64
	Key PRGKey
	// contains filtered or unexported fields
}

func NewBufPRG

func NewBufPRG(prg *PRGReader) *BufPRGReader

func NewRandomBufPRG

func NewRandomBufPRG() *BufPRGReader

func (*BufPRGReader) Int63

func (b *BufPRGReader) Int63() int64

func (*BufPRGReader) MathRand

func (r *BufPRGReader) MathRand() *mrand.Rand

func (*BufPRGReader) RandInt

func (b *BufPRGReader) RandInt(mod *big.Int) *big.Int

func (*BufPRGReader) Read

func (b *BufPRGReader) Read(p []byte) (int, error)

func (*BufPRGReader) Seed

func (b *BufPRGReader) Seed(int64)

func (*BufPRGReader) Uint64

func (b *BufPRGReader) Uint64() uint64

type PRGKey

type PRGKey [aes.BlockSize]byte

func RandomPRGKey

func RandomPRGKey() *PRGKey

type PRGReader

type PRGReader struct {
	Key PRGKey
	// contains filtered or unexported fields
}

We use the AES-CTR to generate pseudo-random numbers using a stream cipher. Go's native rand.Reader is extremely slow because it makes tons of system calls to generate a small number of pseudo-random bytes.

func NewPRG

func NewPRG(key *PRGKey) *PRGReader

func RandomPRG

func RandomPRG() *PRGReader

func (*PRGReader) Read

func (s *PRGReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL