randomgen.chacha.ChaCha.seed

ChaCha.seed(seed=None, counter=None, key=None)

Seed the generator

This method is called when ChaCha is initialized. It can be called again to re-Seed the generator For details, see ChaCha.

seed{None, int, array_like[uint64], SeedSequence}, optional

Random seed initializing the pseudo-random number generator. Can be an integer in [0, 2**256), an array of 4 uint64 values, a SeedSequence instance or None (the default). If seed is None, then data is read from /dev/urandom (or the Windows analog) if available. If unavailable, a hash of the time and process ID is used.

counter{None, int, array_like[uint64]}, optional

Counter to use in the ChaCha state. Can be either a Python int in [0, 2**128) or a 2-element uint64 array. If not provided, the counter is initialized at 0.

key{None, int, array_like[uint64]}, optional

Key to use in the ChaCha state. Unlike seed, which is run through another RNG before use, the value in key is directly set. Can be either a Python int in [0, 2**256) or a 4-element uint64 array. key and seed cannot both be used.

Raises:

ValueError – If values are out of range for the PRNG.

Notes

The two representation of the counter and key are related through array[i] = (value // 2**(64*i)) % 2**64.