DDH scheme.
More...
Go to the source code of this file.
|
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) |
|
◆ cfe_ddh
cfe_ddh represents a scheme instantiated from the DDH assumption.
◆ 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
-
s | A pointer to an uninitialized struct representing the scheme |
l | The length of input vectors |
modulus_len | The bit length of the modulus |
bound | The 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
-
s | A pointer to an uninitialized struct representing the scheme |
l | The length of input vectors |
modulus_len | The bit length of the modulus |
bound | The bound by which coordinates of input vectors are bounded |
- Returns
- Error code
◆ cfe_ddh_free()
Frees the memory occupied by the struct members. It does not free memory occupied by the struct itself.
- Parameters
-
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
◆ cfe_ddh_copy()
Reconstructs the scheme with the same configuration parameters from an already existing DDH scheme instance.
- Parameters
-
res | A pointer to an uninitialized ddh struct |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
◆ cfe_ddh_master_keys_init()
Initializes the vectors which represent the master secret key and master public key.
- Parameters
-
msk | A pointer to an uninitialized vector |
mpk | A pointer to an uninitialized vector |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
◆ cfe_ddh_ciphertext_init()
Initializes the vector which represents the ciphertext.
- Parameters
-
ciphertext | A pointer to an uninitialized vector |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
◆ cfe_ddh_generate_master_keys()
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
-
msk | A pointer to a vector (master secret key will be stored here) |
mpk | A pointer to a vector (master public key will be stored here) |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
◆ cfe_ddh_derive_fe_key()
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
-
res | The derived key (the value will be stored here) |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
msk | A pointer to the master secret key |
y | A pointer to the input vector |
- Returns
- Error code
◆ cfe_ddh_encrypt()
Encrypts input vector x with the provided master public key. It returns a ciphertext vector. If encryption failed, an error is returned.
- Parameters
-
ciphertext | A pointer to a vector (the resulting ciphertext will be stored here) |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
x | A pointer to the input vector |
mpk | A pointer to the master public key |
- Returns
- Error code
◆ cfe_ddh_decrypt()
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
-
res | The result of the decryption (the value will be stored here) |
s | A pointer to an instance of the scheme (initialized cfe_ddh struct) |
ciphertext | A pointer to the ciphertext vector |
key | The functional encryption key |
y | A pointer to the plaintext vector |
- Returns
- Error code