54 uint32_t
permute(uint32_t x)
const;
64 uint32_t
invert(uint32_t y)
const;
104 static unsigned int ceilLog2(uint32_t n);
113 static uint32_t
mix32(uint32_t x);
120 const unsigned int _n;
MooseRandomPerturbation(uint64_t seed, unsigned int n, unsigned int rounds=8)
Construct a permutation of [0, n) keyed by seed.
static uint32_t mix32(uint32_t x)
Bijective 32-bit avalanche hash (finalizer from Murmur3 / degski hash).
const uint32_t _k0
Lower 32 bits of the seed, used as the first subkey in the round function.
uint32_t permute(uint32_t x) const
Map x to its permuted index in [0, n).
const uint32_t _k1
Upper 32 bits of the seed, used as the second subkey in the round function.
Generates a keyed pseudo-random permutation of the integers [0, n) using a balanced Feistel network...
uint32_t permutePadded(uint32_t x) const
Apply one full pass of the balanced Feistel network over the padded domain [0, 2^(2*half_bits)).
uint32_t invert(uint32_t y) const
Recover the original index from a permuted value, i.e.
const uint32_t _half_mask
Bitmask of width _half_bits, used to keep half-block arithmetic in range.
const unsigned int _half_bits
Number of bits in each Feistel half-block: ceil((ceil(log2(n)) + 1) / 2)
uint32_t roundFunction(uint32_t half, unsigned int round) const
Keyed round function F(half, round) used in each Feistel step.
const unsigned int _rounds
Number of Feistel rounds to apply per permute/invert call.
uint32_t invertPadded(uint32_t y) const
Invert one full pass of the Feistel network by running rounds in reverse.
static unsigned int ceilLog2(uint32_t n)
Return the number of bits needed to represent values in [0, n-1], i.e.
const unsigned int _n
Size of the permutation domain [0, n)