mpyc.random | index github.com/lschoe/mpyc/blob/v0.10/mpyc/random.py |
This module provides secure versions of several functions for
generating pseudorandom numbers, cf. the random module of Python's
standard library. Each function behaves like its Python counterpart,
except that a secure type is required as additional (first) argument.
Additionally, random_unit_vector() generates a random bit vector
with exactly one bit set to 1, using approximately log_2 n secure
random bits for a bit vector of length n.
Also, random_permutation() and random_derangement() are provided as
convenience functions.
Main concern for the implementations is to minimize the randomness
complexity, that is, to limit the usage of secure random bits as
provided by runtime.random_bits(). Other than this, the code is
relatively simple for now.
NB: runtime._random(sectype, n) cannot be used as an alternative to
_randbelow(sectype, n) as its output is not uniformly random, except
when n is equal to the order of sectype's finite field.
Modules | ||||||
|
Functions | ||
|
Data | ||
runtime = None |