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

LWE scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_ring_lwe
 

Typedefs

typedef struct cfe_ring_lwe cfe_ring_lwe
 

Functions

cfe_error cfe_ring_lwe_init (cfe_ring_lwe *s, size_t l, size_t n, mpz_t bound, mpz_t p, mpz_t q, mpf_t sigma)
 
void cfe_ring_lwe_sec_key_init (cfe_mat *SK, cfe_ring_lwe *s)
 
void cfe_ring_lwe_generate_sec_key (cfe_mat *SK, cfe_ring_lwe *s)
 
void cfe_ring_lwe_pub_key_init (cfe_mat *PK, cfe_ring_lwe *s)
 
cfe_error cfe_ring_lwe_generate_pub_key (cfe_mat *PK, cfe_ring_lwe *s, cfe_mat *SK)
 
void cfe_ring_lwe_fe_key_init (cfe_vec *sk_y, cfe_ring_lwe *s)
 
cfe_error cfe_ring_lwe_derive_fe_key (cfe_vec *sk_y, cfe_ring_lwe *s, cfe_mat *SK, cfe_vec *y)
 
void cfe_ring_lwe_ciphertext_init (cfe_mat *CT, cfe_ring_lwe *s)
 
cfe_error cfe_ring_lwe_encrypt (cfe_mat *CT, cfe_ring_lwe *s, cfe_mat *x, cfe_mat *PK)
 
void cfe_ring_lwe_decrypted_init (cfe_vec *res, cfe_ring_lwe *s)
 
cfe_error cfe_ring_lwe_decrypt (cfe_vec *res, cfe_ring_lwe *s, cfe_mat *ct, cfe_vec *sk_y, cfe_vec *y)
 
void cfe_ring_lwe_free (cfe_ring_lwe *s)
 

Detailed Description

LWE scheme.

Typedef Documentation

◆ cfe_ring_lwe

typedef struct cfe_ring_lwe cfe_ring_lwe

cfe_ring_lwe represents common properties of the scheme.

Function Documentation

◆ cfe_ring_lwe_init()

cfe_error cfe_ring_lwe_init ( cfe_ring_lwe s,
size_t  l,
size_t  n,
mpz_t  bound,
mpz_t  p,
mpz_t  q,
mpf_t  sigma 
)

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
boundThe bound by which coordinates of the input vectors are bounded
pModulus for the inner product
qModulus for ciphertext and keys vectors are bounded
sigmaStandard deviation
Returns
Error code

◆ cfe_ring_lwe_sec_key_init()

void cfe_ring_lwe_sec_key_init ( cfe_mat SK,
cfe_ring_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_ring_lwe struct)

◆ cfe_ring_lwe_generate_sec_key()

void cfe_ring_lwe_generate_sec_key ( cfe_mat SK,
cfe_ring_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_ring_lwe struct)

◆ cfe_ring_lwe_pub_key_init()

void cfe_ring_lwe_pub_key_init ( cfe_mat PK,
cfe_ring_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_ring_lwe struct)

◆ cfe_ring_lwe_generate_pub_key()

cfe_error cfe_ring_lwe_generate_pub_key ( cfe_mat PK,
cfe_ring_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_ring_lwe struct)
SKA pointer to an initialized matrix representing the secret key.
Returns
Error code

◆ cfe_ring_lwe_fe_key_init()

void cfe_ring_lwe_fe_key_init ( cfe_vec sk_y,
cfe_ring_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_ring_lwe struct)

◆ cfe_ring_lwe_derive_fe_key()

cfe_error cfe_ring_lwe_derive_fe_key ( cfe_vec sk_y,
cfe_ring_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)
sA pointer to an instance of the scheme (initialized cfe_ring_lwe struct)
SKA pointer to the master secret key
yA pointer to the inner product vector
Returns
Error code

◆ cfe_ring_lwe_ciphertext_init()

void cfe_ring_lwe_ciphertext_init ( cfe_mat CT,
cfe_ring_lwe s 
)

Initializes the matrix which represents the ciphertext.

Parameters
CTA pointer to an uninitialized matrix
sA pointer to an instance of the scheme (initialized cfe_ring_lwe struct)

◆ cfe_ring_lwe_encrypt()

cfe_error cfe_ring_lwe_encrypt ( cfe_mat CT,
cfe_ring_lwe s,
cfe_mat x,
cfe_mat PK 
)

Encrypts input matrix x with the provided master public key.

Parameters
CTA pointer to a matrix (the resulting ciphertext will be stored here)
sA pointer to an instance of the scheme (initialized cfe_ring_lwe struct)
xA pointer to the input matrix
PKA pointer to the matrix representing the public key.
Returns
Error code

◆ cfe_ring_lwe_decrypted_init()

void cfe_ring_lwe_decrypted_init ( cfe_vec res,
cfe_ring_lwe s 
)

Initialized the vector which represents the result of the decryption.

Parameters
resA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_ring_lwe struct)

◆ cfe_ring_lwe_decrypt()

cfe_error cfe_ring_lwe_decrypt ( cfe_vec res,
cfe_ring_lwe s,
cfe_mat ct,
cfe_vec sk_y,
cfe_vec y 
)

Accepts the encrypted matrix X, functional encryption key, and an inner product vector y. It returns the product y^T * X. If decryption failed, an error is returned.

Parameters
resA pointer to a vector (result of the decryption will be stored here)
sA pointer to an instance of the scheme (initialized cfe_ring_lwe struct)
ctA pointer to the ciphertext matrix
sk_yThe functional encryption key
yA pointer to the inner product vector
Returns
Error code

◆ cfe_ring_lwe_free()

void cfe_ring_lwe_free ( cfe_ring_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_ring_lwe struct)