HC-128 Cipher Generator

class randomgen.efiix64.EFIIX64(seed=None)

Container for the EFIIX64x384 pseudo-random number generator.

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

Entropy initializing the pseudo-random number generator. Can be an integer in [0, 2**64), array of integers in [0, 2**64), 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.

Notes

EFIIX64 (also known as efiix64x384) is written by Chris Doty-Humphrey. It is a 64-bit PRNG that uses a set of tables generate random values. This produces a fast PRNG with statistical quality similar to cryptographic generators but faster [1].

EFIIX64 provides a capsule containing function pointers that produce doubles, and unsigned 32 and 64- bit integers. These are not directly consumable in Python and must be consumed by a Generator or similar object that supports low-level access.

State and Seeding

The EFIIX64 state vector consists of a 16-element array of 64-bit unsigned integers and a 32-element array of 64-bit unsigned integers. In addition, 3 constant values and a counter are used in the update.

EFIIX64 is seeded using an integer, a sequence of integer or a SeedSequence. If the seed is not SeedSequence, the seed values are passed to a SeedSequence which is then used to produce 4 64-bit unsigned integer values which are used to Seed the generator

Compatibility Guarantee

EFIIX64 makes a guarantee that a fixed seed will always produce the same random integer stream.

References

1

Random, P., 2020. Practically Random / Discussion / Open Discussion: Is Too Low A Chi-Squared Sum Really A Problem?. [online] Sourceforge.net. Available at: https://sourceforge.net/p/pracrand/discussion/366935/thread/c73ddb7b/#d0fc [Accessed 22 June 2020].

Examples

>>> from randomgen import Generator, EFIIX64
>>> rg = Generator(EFIIX64(1234))
>>> rg.standard_normal()
0.123  # random

Parallel Features

EFIIX64 can be used in parallel when combined with a SeedSequence using spawn.

>>> from randomgen import SeedSequence
>>> ss = SeedSequence(8509285875904376097169743623867)
>>> bit_gens = [EFIIX64(child) for child in ss.spawn(1024)]
Attributes
lockthreading.Lock

Lock instance that is shared so that the same bit git generator can be used in multiple Generators without corrupting the state. Code that generates values from a bit generator should hold the bit generator’s lock.

seed_seq{None, SeedSequence}

The SeedSequence instance used to initialize the generator if mode is “sequence” or is seed is a SeedSequence. None if mode is “legacy”.

Seeding and State

seed([seed])

Seed the generator

state

Get or set the PRNG state

Extending

cffi

CFFI interface

ctypes

ctypes interface

Testing

random_raw([size, output])

Return randoms as generated by the underlying BitGenerator