CiFEr
Data Structures | Typedefs | Functions

LWE scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_lwe_fs
 

Typedefs

typedef struct cfe_lwe_fs cfe_lwe_fs
 

Functions

cfe_error cfe_lwe_fs_init (cfe_lwe_fs *s, size_t l, size_t n, mpz_t bound_x, mpz_t bound_y)
 
void cfe_lwe_fs_sec_key_init (cfe_mat *SK, cfe_lwe_fs *s)
 
void cfe_lwe_fs_generate_sec_key (cfe_mat *SK, cfe_lwe_fs *s)
 
void cfe_lwe_fs_pub_key_init (cfe_mat *PK, cfe_lwe_fs *s)
 
cfe_error cfe_lwe_fs_generate_pub_key (cfe_mat *PK, cfe_lwe_fs *s, cfe_mat *SK)
 
void cfe_lwe_fs_fe_key_init (cfe_vec *z_y, cfe_lwe_fs *s)
 
cfe_error cfe_lwe_fs_derive_fe_key (cfe_vec *z_y, cfe_lwe_fs *s, cfe_vec *y, cfe_mat *SK)
 
void cfe_lwe_fs_ciphertext_init (cfe_vec *ct, cfe_lwe_fs *s)
 
cfe_error cfe_lwe_fs_encrypt (cfe_vec *ct, cfe_lwe_fs *s, cfe_vec *x, cfe_mat *PK)
 
cfe_error cfe_lwe_fs_decrypt (mpz_t res, cfe_lwe_fs *s, cfe_vec *ct, cfe_vec *z_y, cfe_vec *y)
 
void cfe_lwe_fs_free (cfe_lwe_fs *s)
 

Detailed Description

LWE scheme.

Typedef Documentation

◆ cfe_lwe_fs

typedef struct cfe_lwe_fs cfe_lwe_fs

lwe_fs represents common properties of the scheme.

Function Documentation

◆ cfe_lwe_fs_init()

cfe_error cfe_lwe_fs_init ( cfe_lwe_fs s,
size_t  l,
size_t  n,
mpz_t  bound_x,
mpz_t  bound_y 
)

Configures a new instance of the scheme.

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
nThe security parameter of the scheme
bound_xThe bound by which coordinates of the encrypted vectors are bounded
bound_yThe bound by which coordinates of the inner product vectors are bounded
Returns
Error code

◆ cfe_lwe_fs_sec_key_init()

void cfe_lwe_fs_sec_key_init ( cfe_mat SK,
cfe_lwe_fs s 
)

Initializes the matrix which represents the secret key.

Parameters
SKA pointer to an uninitialized matrix
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)

◆ cfe_lwe_fs_generate_sec_key()

void cfe_lwe_fs_generate_sec_key ( cfe_mat SK,
cfe_lwe_fs s 
)

Generates a private secret key for the scheme.

Parameters
SKA pointer to a matrix (master secret key will be stored here)
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)

◆ cfe_lwe_fs_pub_key_init()

void cfe_lwe_fs_pub_key_init ( cfe_mat PK,
cfe_lwe_fs s 
)

Initializes the matrix which represents the public key.

Parameters
PKA pointer to an uninitialized matrix
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)

◆ cfe_lwe_fs_generate_pub_key()

cfe_error cfe_lwe_fs_generate_pub_key ( cfe_mat PK,
cfe_lwe_fs s,
cfe_mat SK 
)

Generates a public key for the scheme.

Parameters
PKA pointer to a matrix (master public key will be stored here)
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)
SKA pointer to an initialized matrix representing the secret key.
Returns
Error code

◆ cfe_lwe_fs_fe_key_init()

void cfe_lwe_fs_fe_key_init ( cfe_vec z_y,
cfe_lwe_fs s 
)

Initializes the vector which represents the functional encryption key.

Parameters
z_yA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)

◆ cfe_lwe_fs_derive_fe_key()

cfe_error cfe_lwe_fs_derive_fe_key ( cfe_vec z_y,
cfe_lwe_fs s,
cfe_vec y,
cfe_mat SK 
)

Takes master secret key and inner product vector, and returns the functional encryption key.

Parameters
z_yA pointer to an initialized functional encryption key, which will be stored here
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)
yA pointer to the input vector
SKA pointer to the master secret key
Returns
Error code

◆ cfe_lwe_fs_ciphertext_init()

void cfe_lwe_fs_ciphertext_init ( cfe_vec ct,
cfe_lwe_fs s 
)

Initializes the vector which represents the ciphertext.

Parameters
ctA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)

◆ cfe_lwe_fs_encrypt()

cfe_error cfe_lwe_fs_encrypt ( cfe_vec ct,
cfe_lwe_fs s,
cfe_vec x,
cfe_mat PK 
)

Encrypts input vector x with the provided master public key.

Parameters
ctA pointer to a vector (the resulting ciphertext will be stored here)
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)
xA pointer to the input vector
PKA pointer to a matrix - master public key.
Returns
Error code

◆ cfe_lwe_fs_decrypt()

cfe_error cfe_lwe_fs_decrypt ( mpz_t  res,
cfe_lwe_fs s,
cfe_vec ct,
cfe_vec z_y,
cfe_vec y 
)

Accepts the encrypted vector, functional encryption key, and a plaintext vector. It returns the inner product. If decryption failed, an error is returned.

Parameters
resThe result of the decryption (the value will be stored here)
sA pointer to an instance of the scheme (initialized cfe_lwe_fs struct)
ctA pointer to the vector representing the ciphertext
z_yA pointer to the functional encryption key vector
yA pointer to the inner product vector
Returns
Error code

◆ cfe_lwe_fs_free()

void cfe_lwe_fs_free ( cfe_lwe_fs 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 scheme (initialized cfe_lwe_fs struct)