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

Paillier scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_paillier
 

Typedefs

typedef struct cfe_paillier cfe_paillier
 

Functions

cfe_error cfe_paillier_init (cfe_paillier *s, size_t l, size_t lambda, size_t bit_len, mpz_t bound_x, mpz_t bound_y)
 
void cfe_paillier_free (cfe_paillier *s)
 
void cfe_paillier_copy (cfe_paillier *res, cfe_paillier *s)
 
void cfe_paillier_master_keys_init (cfe_vec *msk, cfe_vec *mpk, cfe_paillier *s)
 
cfe_error cfe_paillier_generate_master_keys (cfe_vec *msk, cfe_vec *mpk, cfe_paillier *s)
 
cfe_error cfe_paillier_derive_fe_key (mpz_t fe_key, cfe_paillier *s, cfe_vec *msk, cfe_vec *y)
 
void cfe_paillier_ciphertext_init (cfe_vec *ciphertext, cfe_paillier *s)
 
cfe_error cfe_paillier_encrypt (cfe_vec *ciphertext, cfe_paillier *s, cfe_vec *x, cfe_vec *mpk)
 
cfe_error cfe_paillier_decrypt (mpz_t res, cfe_paillier *s, cfe_vec *ciphertext, mpz_t key, cfe_vec *y)
 

Detailed Description

Paillier scheme.

Typedef Documentation

◆ cfe_paillier

typedef struct cfe_paillier cfe_paillier

cfe_paillier represents common properties of the scheme.

Function Documentation

◆ cfe_paillier_init()

cfe_error cfe_paillier_init ( cfe_paillier s,
size_t  l,
size_t  lambda,
size_t  bit_len,
mpz_t  bound_x,
mpz_t  bound_y 
)

Initializes a new instance of the scheme. It accepts the length of input vectors l, security parameter lambda, the bit length of prime numbers (giving security to the scheme, it should be such that factoring two primes with such a bit length takes at least 2^lambda operations), and boundX and boundY by which coordinates of input vectors and inner product vectors are bounded. It returns an error in the case the scheme could not be properly configured, or if the precondition boundX, boundY < (n / l)^(1/2) is not satisfied.

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
lambdaThe security parameter
bit_lenNumber of bits for generating prime numbers
bound_xThe bound by which the coordinates of encrypted vectors are bounded
bound_yThe bound by which the coordinates of inner product vectors are bounded
Returns
Error code

◆ cfe_paillier_free()

void cfe_paillier_free ( cfe_paillier 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_paillier struct)

◆ cfe_paillier_copy()

void cfe_paillier_copy ( cfe_paillier res,
cfe_paillier s 
)

Reconstructs the scheme with the same configuration parameters from an already existing Paillier scheme instance.

Parameters
resA pointer to an uninitialized paillier struct
sA pointer to an instance of the scheme (initialized cfe_paillier struct)

◆ cfe_paillier_master_keys_init()

void cfe_paillier_master_keys_init ( cfe_vec msk,
cfe_vec mpk,
cfe_paillier s 
)

Initializes the vectors which represent the master secret key and master public key.

Parameters
mskA pointer to an uninitialized vector
mpkA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_paillier struct)

◆ cfe_paillier_generate_master_keys()

cfe_error cfe_paillier_generate_master_keys ( cfe_vec msk,
cfe_vec mpk,
cfe_paillier s 
)

Generates a master secret key and master public key for the scheme.

Parameters
mskA pointer to a vector (master secret key will be stored here)
mpkA pointer to a vector (master public key will be stored here)
sA pointer to an instance of the scheme (initialized cfe_paillier struct)
Returns
Error code

◆ cfe_paillier_derive_fe_key()

cfe_error cfe_paillier_derive_fe_key ( mpz_t  fe_key,
cfe_paillier s,
cfe_vec msk,
cfe_vec y 
)

Takes master secret key and input vector y, and returns the functional encryption key. In case the key could not be derived, it returns an error.

Parameters
fe_keyThe resulting functional encryption key (the value will be stored here)
sA pointer to an instance of the scheme (initialized cfe_paillier struct)
mskA pointer to the master secret key
yA pointer to the inner product vector
Returns
Error code

◆ cfe_paillier_ciphertext_init()

void cfe_paillier_ciphertext_init ( cfe_vec ciphertext,
cfe_paillier s 
)

Initializes the vector which represents the ciphertext.

Parameters
ciphertextA pointer to an uninitialized vector
sA pointer to an instance of the scheme (initialized cfe_paillier struct)

◆ cfe_paillier_encrypt()

cfe_error cfe_paillier_encrypt ( cfe_vec ciphertext,
cfe_paillier s,
cfe_vec x,
cfe_vec mpk 
)

Encrypts input vector x with the provided master public key. It returns a ciphertext vector. If encryption failed, an error is returned.

Parameters
ciphertextA pointer to a vector (the resulting ciphertext will be stored here)
sA pointer to an instance of the scheme (initialized cfe_paillier struct)
xA pointer to the input vector
mpkA pointer to the master public key
Returns
Error code

◆ cfe_paillier_decrypt()

cfe_error cfe_paillier_decrypt ( mpz_t  res,
cfe_paillier s,
cfe_vec ciphertext,
mpz_t  key,
cfe_vec y 
)

Accepts the encrypted vector, functional encryption key, and a plaintext vector y. It returns the inner product of x and y. 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_paillier struct)
ciphertextA pointer to the ciphertext vector
keyThe functional encryption key
yA pointer to the inner product vector
Returns
Error code