Uniform samplers.
More...
Go to the source code of this file.
|
void | cfe_uniform_sample (mpz_t res, mpz_t upper) |
|
void | cfe_uniform_sample_i (mpz_t res, size_t upper) |
|
void | cfe_uniform_sample_range (mpz_t res, mpz_t min, mpz_t max) |
|
void | cfe_uniform_sample_range_i_mpz (mpz_t res, int min, mpz_t max) |
|
void | cfe_uniform_sample_range_i_i (mpz_t res, int min, int max) |
|
void | cfe_uniform_sample_vec (cfe_vec *res, mpz_t max) |
|
void | cfe_uniform_sample_range_vec (cfe_vec *res, mpz_t lower, mpz_t upper) |
|
void | cfe_uniform_sample_mat (cfe_mat *res, mpz_t max) |
|
void | cfe_uniform_sample_range_mat (cfe_mat *res, mpz_t lower, mpz_t upper) |
|
bool | cfe_bit_sample (void) |
|
void | cfe_uniform_sample_vec_det (cfe_vec *res, mpz_t max, unsigned char *key) |
|
void | cfe_uniform_sample_mat_det (cfe_mat *res, mpz_t max, unsigned char *key) |
|
◆ cfe_uniform_sample()
void cfe_uniform_sample |
( |
mpz_t |
res, |
|
|
mpz_t |
upper |
|
) |
| |
Returns a random number from the range [0, upper). Relies on OS's entropy source and is cryptographically secure.
- Parameters
-
res | The random number (result value will be stored here) |
upper | Upper bound for sampling |
◆ cfe_uniform_sample_i()
void cfe_uniform_sample_i |
( |
mpz_t |
res, |
|
|
size_t |
upper |
|
) |
| |
Integer version of uniform_sample.
◆ cfe_uniform_sample_range()
void cfe_uniform_sample_range |
( |
mpz_t |
res, |
|
|
mpz_t |
min, |
|
|
mpz_t |
max |
|
) |
| |
Returns a random number from the range [min, max). Relies on OS's entropy source and is cryptographically secure.
- Parameters
-
res | The random number (result value will be stored here) |
min | Minimum value for sampling |
max | Maximum value for sampling |
◆ cfe_uniform_sample_range_i_mpz()
void cfe_uniform_sample_range_i_mpz |
( |
mpz_t |
res, |
|
|
int |
min, |
|
|
mpz_t |
max |
|
) |
| |
Integer version of uniform_sample_range.
◆ cfe_uniform_sample_range_i_i()
void cfe_uniform_sample_range_i_i |
( |
mpz_t |
res, |
|
|
int |
min, |
|
|
int |
max |
|
) |
| |
Integer version of uniform_sample_range.
◆ cfe_uniform_sample_vec()
void cfe_uniform_sample_vec |
( |
cfe_vec * |
res, |
|
|
mpz_t |
max |
|
) |
| |
Sets the elements of a vector to uniform random integers < max.
◆ cfe_uniform_sample_range_vec()
void cfe_uniform_sample_range_vec |
( |
cfe_vec * |
res, |
|
|
mpz_t |
lower, |
|
|
mpz_t |
upper |
|
) |
| |
Sets the elements of a vector to uniform random integers in [lower, upper).
◆ cfe_uniform_sample_mat()
void cfe_uniform_sample_mat |
( |
cfe_mat * |
res, |
|
|
mpz_t |
max |
|
) |
| |
Sets the elements of a matrix to uniform random integers < max.
◆ cfe_uniform_sample_range_mat()
void cfe_uniform_sample_range_mat |
( |
cfe_mat * |
res, |
|
|
mpz_t |
lower, |
|
|
mpz_t |
upper |
|
) |
| |
Sets the elements of a matrix to uniform random integers in [lower, upper).
◆ cfe_bit_sample()
bool cfe_bit_sample |
( |
void |
| ) |
|
Returns a random boolean value.
- Returns
- Random boolean value
◆ cfe_uniform_sample_vec_det()
void cfe_uniform_sample_vec_det |
( |
cfe_vec * |
res, |
|
|
mpz_t |
max, |
|
|
unsigned char * |
key |
|
) |
| |
Sets the elements of a vector to pseudo-uniform random integers < max, completely determined by the given key.
- Parameters
-
res | A pointer to a vector, the result will be saved here |
max | Maximum value of elements of the sampled vector |
key | A key to generate pseudo-random values; it should be a string of length 32, i.e. 256 bit value |
◆ cfe_uniform_sample_mat_det()
void cfe_uniform_sample_mat_det |
( |
cfe_mat * |
res, |
|
|
mpz_t |
max, |
|
|
unsigned char * |
key |
|
) |
| |
Sets the elements of a matrix to pseudo-uniform random integers < max, completely determined by the given key.
- Parameters
-
res | A pointer to a matrix, the result will be saved here |
max | Maximum value of elements of the sampled matrix |
key | A key to generate pseudo-random values; it should be a string of length 32, i.e. 256 bit value |