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

DDH multi input scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_ddh_multi
 
struct  cfe_ddh_multi_sec_key
 
struct  cfe_ddh_multi_fe_key
 
struct  cfe_ddh_multi_enc
 

Typedefs

typedef struct cfe_ddh_multi cfe_ddh_multi
 
typedef struct cfe_ddh_multi_sec_key cfe_ddh_multi_sec_key
 
typedef struct cfe_ddh_multi_fe_key cfe_ddh_multi_fe_key
 
typedef struct cfe_ddh_multi_enc cfe_ddh_multi_enc
 

Functions

cfe_error cfe_ddh_multi_init (cfe_ddh_multi *m, size_t slots, size_t l, size_t modulus_len, mpz_t bound)
 
cfe_error cfe_ddh_multi_precomp_init (cfe_ddh_multi *m, size_t slots, size_t l, size_t modulus_len, mpz_t bound)
 
void cfe_ddh_multi_free (cfe_ddh_multi *m)
 
void cfe_ddh_multi_copy (cfe_ddh_multi *res, cfe_ddh_multi *m)
 
void cfe_ddh_multi_enc_init (cfe_ddh_multi_enc *e, cfe_ddh_multi *m)
 
void cfe_ddh_multi_enc_free (cfe_ddh_multi_enc *e)
 
void cfe_ddh_multi_sec_key_free (cfe_ddh_multi_sec_key *key)
 
void cfe_ddh_multi_fe_key_free (cfe_ddh_multi_fe_key *key)
 
void cfe_ddh_multi_master_keys_init (cfe_mat *mpk, cfe_ddh_multi_sec_key *msk, cfe_ddh_multi *m)
 
void cfe_ddh_multi_fe_key_init (cfe_ddh_multi_fe_key *key, cfe_ddh_multi *m)
 
void cfe_ddh_multi_ciphertext_init (cfe_vec *ciphertext, cfe_ddh_multi_enc *e)
 
void cfe_ddh_multi_generate_master_keys (cfe_mat *mpk, cfe_ddh_multi_sec_key *msk, cfe_ddh_multi *m)
 
cfe_error cfe_ddh_multi_derive_fe_key (cfe_ddh_multi_fe_key *res, cfe_ddh_multi *m, cfe_ddh_multi_sec_key *msk, cfe_mat *y)
 
cfe_error cfe_ddh_multi_encrypt (cfe_vec *ciphertext, cfe_ddh_multi_enc *e, cfe_vec *x, cfe_vec *pub_key, cfe_vec *otp)
 
cfe_error cfe_ddh_multi_decrypt (mpz_t res, cfe_ddh_multi *m, cfe_mat *ciphertext, cfe_ddh_multi_fe_key *key, cfe_mat *y)
 

Detailed Description

DDH multi input scheme.

Typedef Documentation

◆ cfe_ddh_multi

typedef struct cfe_ddh_multi cfe_ddh_multi

cfe_ddh_multi represents a multi input variant of the underlying DDH scheme.

◆ cfe_ddh_multi_sec_key

cfe_ddh_multi_sec_key is a secret key for DDH multi input scheme.

◆ cfe_ddh_multi_fe_key

cfe_ddh_multi_fe_key is a functional encryption key for DDH multi input scheme.

◆ cfe_ddh_multi_enc

cfe_ddh_multi_enc represents a single encryptor for the ddh_multi scheme.

Function Documentation

◆ cfe_ddh_multi_init()

cfe_error cfe_ddh_multi_init ( cfe_ddh_multi m,
size_t  slots,
size_t  l,
size_t  modulus_len,
mpz_t  bound 
)

Configures a new instance of the scheme. It accepts the number of slots (encryptors), the length of input vectors l, the bit length of the modulus (we are operating in the Z_p group), and a bound by which coordinates of input vectors are bounded.

Parameters
mA pointer to an uninitialized struct representing the scheme
slotsThe number of slots (encryptors)
lThe length of input vectors
modulus_lenThe bit length of the modulus (we are operating in the Z_p group)
boundThe bound by which coordinates of input vectors are bounded.
Returns
Error code

◆ cfe_ddh_multi_precomp_init()

cfe_error cfe_ddh_multi_precomp_init ( cfe_ddh_multi m,
size_t  slots,
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 accepts the number of slots (encryptors), the length of input vectors l, the bit length of the modulus (we are operating in the Z_p group), and a bound by which coordinates of input vectors are bounded.

Parameters
mA pointer to an uninitialized struct representing the scheme
slotsThe number of slots (encryptors)
lThe length of input vectors
modulus_lenThe bit length of the modulus (we are operating in the Z_p group)
boundThe bound by which coordinates of input vectors are bounded.
Returns
Error code

◆ cfe_ddh_multi_free()

void cfe_ddh_multi_free ( cfe_ddh_multi m)

Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.

Parameters
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_copy()

void cfe_ddh_multi_copy ( cfe_ddh_multi res,
cfe_ddh_multi m 
)

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

Parameters
resA pointer to an uninitialized cfe_ddh_multi struct
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_enc_init()

void cfe_ddh_multi_enc_init ( cfe_ddh_multi_enc e,
cfe_ddh_multi m 
)

Takes configuration parameters of a scheme instance, and instantiates a new ddh_multi_enc.

Parameters
eA pointer to an uninitialized struct representing the encryptor for the scheme.
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_enc_free()

void cfe_ddh_multi_enc_free ( cfe_ddh_multi_enc e)

Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.

Parameters
eA pointer to an instance of the encryptor (initialized cfe_ddh_multi_enc struct)

◆ cfe_ddh_multi_sec_key_free()

void cfe_ddh_multi_sec_key_free ( cfe_ddh_multi_sec_key key)

Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.

Parameters
keyA pointer to an initialized cfe_ddh_multi_sec_key struct

◆ cfe_ddh_multi_fe_key_free()

void cfe_ddh_multi_fe_key_free ( cfe_ddh_multi_fe_key key)

Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.

Parameters
keyA pointer to an initialized cfe_ddh_multi_fe_key struct

◆ cfe_ddh_multi_master_keys_init()

void cfe_ddh_multi_master_keys_init ( cfe_mat mpk,
cfe_ddh_multi_sec_key msk,
cfe_ddh_multi m 
)

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

Parameters
mskA pointer to an uninitialized matrix
mpkA pointer to an uninitialized cfe_dhh_multi_sec_key struct
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_fe_key_init()

void cfe_ddh_multi_fe_key_init ( cfe_ddh_multi_fe_key key,
cfe_ddh_multi m 
)

Initializes the struct which represents the functional encryption key.

Parameters
keyA pointer to an uninitialized cfe_dhh_multi_fe_key struct
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_ciphertext_init()

void cfe_ddh_multi_ciphertext_init ( cfe_vec ciphertext,
cfe_ddh_multi_enc e 
)

Initializes the vector which represents the ciphertext.

Parameters
ciphertextA pointer to an uninitialized vector
eA pointer to an instance of the encryptor (initialized cfe_ddh_multi_enc struct)

◆ cfe_ddh_multi_generate_master_keys()

void cfe_ddh_multi_generate_master_keys ( cfe_mat mpk,
cfe_ddh_multi_sec_key msk,
cfe_ddh_multi m 
)

Generates a matrix comprised of master public keys and a struct encapsulating master secret keys for the scheme. It returns an error in case master keys could not be generated.

Parameters
mpkA pointer to a matrix (master public key will be stored here)
mskA pointer to a cfe_ddh_multi_sec_key struct (master secret key will be stored here)
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)

◆ cfe_ddh_multi_derive_fe_key()

cfe_error cfe_ddh_multi_derive_fe_key ( cfe_ddh_multi_fe_key res,
cfe_ddh_multi m,
cfe_ddh_multi_sec_key msk,
cfe_mat y 
)

Takes master secret key and a matrix y comprised of input vectors, and returns the functional encryption key. In case the key could not be derived, it returns an error.

Parameters
resA pointer to a cfe_ddh_multi_fe_key struct (the functional encryption key will be stored here)
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)
mskA pointer to the master secret key
yA pointer to the matrix comprised of input vectors
Returns
Error code

◆ cfe_ddh_multi_encrypt()

cfe_error cfe_ddh_multi_encrypt ( cfe_vec ciphertext,
cfe_ddh_multi_enc e,
cfe_vec x,
cfe_vec pub_key,
cfe_vec otp 
)

Generates a ciphertext from the input vector x with the provided public key and one-time pad otp (which is a part of the secret key). It returns the ciphertext vector. If encryption failed, an error is returned.

Parameters
ciphertextA pointer to a vector (the resulting ciphertext will be stored here)
eA pointer to an instance of the encryptor (initialized cfe_ddh_multi_enc struct)
xA pointer to the input vector
pub_keyA pointer to the public key vector
otpA pointer to the one-time pad vector
Returns
Error code

◆ cfe_ddh_multi_decrypt()

cfe_error cfe_ddh_multi_decrypt ( mpz_t  res,
cfe_ddh_multi m,
cfe_mat ciphertext,
cfe_ddh_multi_fe_key key,
cfe_mat y 
)

Accepts the matrix cipher comprised of encrypted vectors, functional encryption key, and a matrix y comprised of plaintext vectors. It returns the sum of inner products. If decryption failed, an error is returned.

Parameters
resThe result of the decryption (the value will be stored here)
mA pointer to an instance of the scheme (initialized cfe_ddh_multi struct)
ciphertextA pointer to the matrix comprised of encrypted vectors
keyA pointer to the functional encryption key
yA pointer to the matrix comprised of plaintext vectors
Returns
Error code