CiFEr
Data Structures | Typedefs | Functions
normal_double_constant.h File Reference

Normal constant time sampler based on double sampling. More...

Go to the source code of this file.

Data Structures

struct  cfe_normal_double_constant
 

Typedefs

typedef struct cfe_normal_double_constant cfe_normal_double_constant
 

Functions

void cfe_normal_double_constant_init (cfe_normal_double_constant *s, mpz_t k)
 
void cfe_normal_double_constant_free (cfe_normal_double_constant *s)
 
void cfe_normal_double_constant_sample (mpz_t res, cfe_normal_double_constant *s)
 
void cfe_normal_double_constant_sample_vec (cfe_vec *res, cfe_normal_double_constant *s)
 
void cfe_normal_double_constant_sample_mat (cfe_mat *res, cfe_normal_double_constant *s)
 

Detailed Description

Normal constant time sampler based on double sampling.

Typedef Documentation

◆ cfe_normal_double_constant

cfe_normal_double_constant samples random values from the normal (Gaussian) probability distribution, centered on 0. This sampler works in a way that it first samples from a cfe_normal_cdt - normal distribution with fixed sigma - and then using another sampling from uniform distribution creates a candidate for the output, which is accepted or rejected with certain probability. The sampler algorithm is constant time in the sense that the sampled value is independent of the time needed. The implementation is based on paper: "FACCT: FAst, Compact, and Constant-Time Discrete Gaussian Sampler over Integers" by R. K. Zhao, R. Steinfeld, and A. Sakzad, see https://eprint.iacr.org/2018/1234.pdf. See the above paper for the argumentation of the choice of parameters and proof of precision and security.

Function Documentation

◆ cfe_normal_double_constant_init()

void cfe_normal_double_constant_init ( cfe_normal_double_constant s,
mpz_t  k 
)

Initializes an instance of cfe_normal_double_constant sampler. It assumes mean = 0. Parameter k needs to be given, such that sigma = k * sqrt(1/(2ln(2))).

Parameters
sA pointer to an uninitialized struct representing the sampler
kThe value determining sigma = k * sqrt(1/(2ln(2)))

◆ cfe_normal_double_constant_free()

void cfe_normal_double_constant_free ( cfe_normal_double_constant s)

Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.

Parameters
sA pointer to an instance of the sampler (initialized cfe_normal_double_constant struct)

◆ cfe_normal_double_constant_sample()

void cfe_normal_double_constant_sample ( mpz_t  res,
cfe_normal_double_constant s 
)

Samples according to discrete Gaussian distribution using cfe_normal_double_constant.

Parameters
resThe sampling value (result value will be stored here)
sA pointer to an instance of the sampler (initialized cfe_normal_double_constant struct)

◆ cfe_normal_double_constant_sample_vec()

void cfe_normal_double_constant_sample_vec ( cfe_vec res,
cfe_normal_double_constant s 
)

Sets the elements of the vector to random numbers with the cfe_normal_double_constant sampler.

◆ cfe_normal_double_constant_sample_mat()

void cfe_normal_double_constant_sample_mat ( cfe_mat res,
cfe_normal_double_constant s 
)

Sets the elements of a matrix to random numbers with the cfe_normal_double_constant sampler.