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

LWE scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_lwe
 

Typedefs

typedef struct cfe_lwe cfe_lwe
 

Functions

cfe_error cfe_lwe_init (cfe_lwe *s, size_t l, mpz_t bound_x, mpz_t bound_y, size_t n)
 
void cfe_lwe_sec_key_init (cfe_mat *SK, cfe_lwe *s)
 
void cfe_lwe_generate_sec_key (cfe_mat *SK, cfe_lwe *s)
 
void cfe_lwe_pub_key_init (cfe_mat *PK, cfe_lwe *s)
 
cfe_error cfe_lwe_generate_pub_key (cfe_mat *PK, cfe_lwe *s, cfe_mat *SK)
 
void cfe_lwe_fe_key_init (cfe_vec *sk_y, cfe_lwe *s)
 
cfe_error cfe_lwe_derive_fe_key (cfe_vec *sk_y, cfe_lwe *s, cfe_mat *SK, cfe_vec *y)
 
void cfe_lwe_ciphertext_init (cfe_vec *ct, cfe_lwe *s)
 
cfe_error cfe_lwe_encrypt (cfe_vec *ct, cfe_lwe *s, cfe_vec *x, cfe_mat *PK)
 
cfe_error cfe_lwe_decrypt (mpz_t res, cfe_lwe *s, cfe_vec *c, cfe_vec *sk_y, cfe_vec *y)
 
void cfe_lwe_free (cfe_lwe *s)
 

Detailed Description

LWE scheme.

Typedef Documentation

◆ cfe_lwe

typedef struct cfe_lwe cfe_lwe

cfe_lwe represents common properties of the scheme.

Function Documentation

◆ cfe_lwe_init()

cfe_error cfe_lwe_init ( cfe_lwe s,
size_t  l,
mpz_t  bound_x,
mpz_t  bound_y,
size_t  n 
)

Configures a new instance of the scheme. Security parameters are generated so that they satisfy theoretical bounds provided in the phd thesis Functional Encryption for Inner-Product Evaluations, see Section 8.3.1 in https://www.di.ens.fr/~fbourse/publications/Thesis.pdf

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
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
nThe security parameter of the scheme
Returns
Error code

◆ cfe_lwe_sec_key_init()

void cfe_lwe_sec_key_init ( cfe_mat SK,
cfe_lwe 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 struct)

◆ cfe_lwe_generate_sec_key()

void cfe_lwe_generate_sec_key ( cfe_mat SK,
cfe_lwe 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 struct)

◆ cfe_lwe_pub_key_init()

void cfe_lwe_pub_key_init ( cfe_mat PK,
cfe_lwe 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 struct)

◆ cfe_lwe_generate_pub_key()

cfe_error cfe_lwe_generate_pub_key ( cfe_mat PK,
cfe_lwe s,
cfe_mat SK 
)

Generates a public key for the scheme.

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

◆ cfe_lwe_fe_key_init()

void cfe_lwe_fe_key_init ( cfe_vec sk_y,
cfe_lwe s 
)

Initializes the vector which represents the functional encryption key.

Parameters
sk_yA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_lwe struct)

◆ cfe_lwe_derive_fe_key()

cfe_error cfe_lwe_derive_fe_key ( cfe_vec sk_y,
cfe_lwe s,
cfe_mat SK,
cfe_vec y 
)

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

Parameters
sk_yA pointer to a vector (the functional encryption key will be stored here)
SKA pointer to the master secret key
sA pointer to an instance of the scheme (initialized cfe_lwe struct)
yA pointer to the inner product vector
Returns
Error code

◆ cfe_lwe_ciphertext_init()

void cfe_lwe_ciphertext_init ( cfe_vec ct,
cfe_lwe 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 struct)

◆ cfe_lwe_encrypt()

cfe_error cfe_lwe_encrypt ( cfe_vec ct,
cfe_lwe 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 struct)
xA pointer to the input vector
PKA pointer to the matrix representing the public key.
Returns
Error code

◆ cfe_lwe_decrypt()

cfe_error cfe_lwe_decrypt ( mpz_t  res,
cfe_lwe s,
cfe_vec c,
cfe_vec sk_y,
cfe_vec y 
)

Accepts the encrypted vector x, 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 struct)
cA pointer to the ciphertext vector
sk_yThe functional encryption key
yA pointer to the inner product vector
Returns
Error code

◆ cfe_lwe_free()

void cfe_lwe_free ( cfe_lwe 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 struct)