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

DDH scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_ddh
 

Typedefs

typedef struct cfe_ddh cfe_ddh
 

Functions

cfe_error cfe_ddh_init (cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound)
 
cfe_error cfe_ddh_precomp_init (cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound)
 
void cfe_ddh_free (cfe_ddh *s)
 
void cfe_ddh_copy (cfe_ddh *res, cfe_ddh *s)
 
void cfe_ddh_master_keys_init (cfe_vec *msk, cfe_vec *mpk, cfe_ddh *s)
 
void cfe_ddh_ciphertext_init (cfe_vec *ciphertext, cfe_ddh *s)
 
void cfe_ddh_generate_master_keys (cfe_vec *msk, cfe_vec *mpk, cfe_ddh *s)
 
cfe_error cfe_ddh_derive_fe_key (mpz_t res, cfe_ddh *s, cfe_vec *msk, cfe_vec *y)
 
cfe_error cfe_ddh_encrypt (cfe_vec *ciphertext, cfe_ddh *s, cfe_vec *x, cfe_vec *mpk)
 
cfe_error cfe_ddh_decrypt (mpz_t res, cfe_ddh *s, cfe_vec *ciphertext, mpz_t key, cfe_vec *y)
 

Detailed Description

DDH scheme.

Typedef Documentation

◆ cfe_ddh

typedef struct cfe_ddh cfe_ddh

cfe_ddh represents a scheme instantiated from the DDH assumption.

Function Documentation

◆ cfe_ddh_init()

cfe_error cfe_ddh_init ( cfe_ddh s,
size_t  l,
size_t  modulus_len,
mpz_t  bound 
)

Configures a new instance of the scheme. It returns an error in case the scheme could not be properly configured, or if precondition 2 * l * bound² is >= order of the cyclic group.

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
modulus_lenThe bit length of the modulus
boundThe bound by which coordinates of input vectors are bounded
Returns
Error code

◆ cfe_ddh_precomp_init()

cfe_error cfe_ddh_precomp_init ( cfe_ddh s,
size_t  l,
size_t  modulus_len,
mpz_t  bound 
)

Configures a new instance of the scheme based on precomputed prime numbers and generators. It returns an error in case the scheme could not be properly configured, or if precondition 2 * l * bound² is >= order of the cyclic group.

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
modulus_lenThe bit length of the modulus
boundThe bound by which coordinates of input vectors are bounded
Returns
Error code

◆ cfe_ddh_free()

void cfe_ddh_free ( cfe_ddh 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_ddh struct)

◆ cfe_ddh_copy()

void cfe_ddh_copy ( cfe_ddh res,
cfe_ddh s 
)

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

Parameters
resA pointer to an uninitialized ddh struct
sA pointer to an instance of the scheme (initialized cfe_ddh struct)

◆ cfe_ddh_master_keys_init()

void cfe_ddh_master_keys_init ( cfe_vec msk,
cfe_vec mpk,
cfe_ddh 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_ddh struct)

◆ cfe_ddh_ciphertext_init()

void cfe_ddh_ciphertext_init ( cfe_vec ciphertext,
cfe_ddh 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_ddh struct)

◆ cfe_ddh_generate_master_keys()

void cfe_ddh_generate_master_keys ( cfe_vec msk,
cfe_vec mpk,
cfe_ddh s 
)

Generates a pair of master secret key and master public key for the scheme. It returns an error in case master keys could not be generated.

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_ddh struct)

◆ cfe_ddh_derive_fe_key()

cfe_error cfe_ddh_derive_fe_key ( mpz_t  res,
cfe_ddh 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
resThe derived key (the value will be stored here)
sA pointer to an instance of the scheme (initialized cfe_ddh struct)
mskA pointer to the master secret key
yA pointer to the input vector
Returns
Error code

◆ cfe_ddh_encrypt()

cfe_error cfe_ddh_encrypt ( cfe_vec ciphertext,
cfe_ddh 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_ddh struct)
xA pointer to the input vector
mpkA pointer to the master public key
Returns
Error code

◆ cfe_ddh_decrypt()

cfe_error cfe_ddh_decrypt ( mpz_t  res,
cfe_ddh s,
cfe_vec ciphertext,
mpz_t  key,
cfe_vec y 
)

Accepts the encrypted vector x, 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_ddh struct)
ciphertextA pointer to the ciphertext vector
keyThe functional encryption key
yA pointer to the plaintext vector
Returns
Error code