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

Damgard scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_damgard
 
struct  cfe_damgard_sec_key
 
struct  cfe_damgard_fe_key
 

Typedefs

typedef struct cfe_damgard cfe_damgard
 
typedef struct cfe_damgard_sec_key cfe_damgard_sec_key
 
typedef struct cfe_damgard_fe_key cfe_damgard_fe_key
 

Functions

cfe_error cfe_damgard_init (cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound)
 
cfe_error cfe_damgard_precomp_init (cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound)
 
void cfe_damgard_free (cfe_damgard *s)
 
void cfe_damgard_copy (cfe_damgard *res, cfe_damgard *s)
 
void cfe_damgard_sec_key_free (cfe_damgard_sec_key *key)
 
void cfe_damgard_fe_key_free (cfe_damgard_fe_key *key)
 
void cfe_damgard_sec_key_init (cfe_damgard_sec_key *msk, cfe_damgard *s)
 
void cfe_damgard_pub_key_init (cfe_vec *mpk, cfe_damgard *s)
 
void cfe_damgard_generate_master_keys (cfe_damgard_sec_key *msk, cfe_vec *mpk, cfe_damgard *s)
 
void cfe_damgard_fe_key_init (cfe_damgard_fe_key *fe_key)
 
cfe_error cfe_damgard_derive_fe_key (cfe_damgard_fe_key *fe_key, cfe_damgard *s, cfe_damgard_sec_key *msk, cfe_vec *y)
 
void cfe_damgard_ciphertext_init (cfe_vec *ciphertext, cfe_damgard *s)
 
cfe_error cfe_damgard_encrypt (cfe_vec *ciphertext, cfe_damgard *s, cfe_vec *x, cfe_vec *mpk)
 
cfe_error cfe_damgard_decrypt (mpz_t res, cfe_damgard *s, cfe_vec *ciphertext, cfe_damgard_fe_key *key, cfe_vec *y)
 

Detailed Description

Damgard scheme.

Typedef Documentation

◆ cfe_damgard

typedef struct cfe_damgard cfe_damgard

cfe_damgard represents a scheme instantiated from the DDH assumption.

◆ cfe_damgard_sec_key

cfe_damgard_sec_key is a secret key for Damgard scheme.

◆ cfe_damgard_fe_key

cfe_damgard_fe_key is a functional encryption key for Damgard scheme.

Function Documentation

◆ cfe_damgard_init()

cfe_error cfe_damgard_init ( cfe_damgard 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_damgard_precomp_init()

cfe_error cfe_damgard_precomp_init ( cfe_damgard 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_damgard_free()

void cfe_damgard_free ( cfe_damgard 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_damgard struct)

◆ cfe_damgard_copy()

void cfe_damgard_copy ( cfe_damgard res,
cfe_damgard s 
)

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

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

◆ cfe_damgard_sec_key_free()

void cfe_damgard_sec_key_free ( cfe_damgard_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_damgard_sec_key struct

◆ cfe_damgard_fe_key_free()

void cfe_damgard_fe_key_free ( cfe_damgard_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_damgard_fe_key struct

◆ cfe_damgard_sec_key_init()

void cfe_damgard_sec_key_init ( cfe_damgard_sec_key msk,
cfe_damgard s 
)

Initializes the struct which represents the master secret key.

Parameters
mskA pointer to an uninitialized cfe_damgard_sec_key struct
sA pointer to an instance of the scheme (initialized cfe_damgard struct)

◆ cfe_damgard_pub_key_init()

void cfe_damgard_pub_key_init ( cfe_vec mpk,
cfe_damgard s 
)

Initializes the vector which represents the master public key.

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

◆ cfe_damgard_generate_master_keys()

void cfe_damgard_generate_master_keys ( cfe_damgard_sec_key msk,
cfe_vec mpk,
cfe_damgard s 
)

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

Parameters
mskA pointer to a cfe_damgard_sec_key struct (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_damgard struct)

◆ cfe_damgard_fe_key_init()

void cfe_damgard_fe_key_init ( cfe_damgard_fe_key fe_key)

Initializes the struct which represents the functional encryption key.

Parameters
fe_keyA pointer to an uninitialized cfe_damgard_fe_key struct

◆ cfe_damgard_derive_fe_key()

cfe_error cfe_damgard_derive_fe_key ( cfe_damgard_fe_key fe_key,
cfe_damgard s,
cfe_damgard_sec_key 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_keyA pointer to a cfe_damgard_fe_key struct (the functional encryption key will be stored here)
sA pointer to an instance of the scheme (initialized cfe_damgard struct)
mskA pointer to the master secret key
yA pointer to the inner product vector
Returns
Error code

◆ cfe_damgard_ciphertext_init()

void cfe_damgard_ciphertext_init ( cfe_vec ciphertext,
cfe_damgard 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_damgard struct)

◆ cfe_damgard_encrypt()

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

◆ cfe_damgard_decrypt()

cfe_error cfe_damgard_decrypt ( mpz_t  res,
cfe_damgard s,
cfe_vec ciphertext,
cfe_damgard_fe_key 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_damgard struct)
ciphertextA pointer to the ciphertext vector
keyThe functional encryption key
yA pointer to the inner product vector
Returns
Error code