CSPRNG based on the Reverie construction, a permutation-based PRNG with forward security, instantiated with the Ascon(128,12,8) permutation.

Compared to ChaCha, this PRNG has a much smaller state, and can be a better choice for constrained environments.

References:

  • A Robust and Sponge-Like PRNG with Improved Efficiency https://eprint.iacr.org/2016/886.pdf
  • Ascon https://ascon.iaik.tugraz.at/files/asconv12-nist.pdf

Fields

state: Ascon,

Functions

fn addEntropy(self: *Self, bytes: []const u8) void

Inserts entropy to refresh the internal state.

fn fill(self: *Self, buf: []u8) void

Fills the buffer with random bytes.

fn init(secret_seed: [secret_seed_length]u8) Self

The seed must be uniform, secret and secret_seed_length bytes long.

fn random(self: *Self) Random

Returns a std.rand.Random structure backed by the current RNG.

Values

secret_seed_length
comptime_int