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

SGP scheme. More...

Go to the source code of this file.

Data Structures

struct  cfe_sgp
 
struct  cfe_sgp_sec_key
 
struct  cfe_sgp_cipher
 

Typedefs

typedef struct cfe_sgp cfe_sgp
 
typedef struct cfe_sgp_sec_key cfe_sgp_sec_key
 
typedef struct cfe_sgp_cipher cfe_sgp_cipher
 

Functions

cfe_error cfe_sgp_init (cfe_sgp *s, size_t l, mpz_t bound)
 
void cfe_sgp_free (cfe_sgp *s)
 
void cfe_sgp_sec_key_init (cfe_sgp_sec_key *msk, cfe_sgp *sgp)
 
void cfe_sgp_sec_key_free (cfe_sgp_sec_key *msk)
 
void cfe_sgp_generate_sec_key (cfe_sgp_sec_key *msk, cfe_sgp *s)
 
cfe_error cfe_sgp_derive_fe_key (ECP2_BN254 *key, cfe_sgp *sgp, cfe_sgp_sec_key *msk, cfe_mat *f)
 
void cfe_sgp_cipher_init (cfe_sgp_cipher *cipher, cfe_sgp *s)
 
void cfe_sgp_cipher_free (cfe_sgp_cipher *cipher)
 
cfe_error cfe_sgp_encrypt (cfe_sgp_cipher *cipher, cfe_sgp *s, cfe_vec *x, cfe_vec *y, cfe_sgp_sec_key *msk)
 
cfe_error cfe_sgp_decrypt (mpz_t res, cfe_sgp *s, cfe_sgp_cipher *cipher, ECP2_BN254 *key, cfe_mat *f)
 

Detailed Description

SGP scheme.

Typedef Documentation

◆ cfe_sgp

typedef struct cfe_sgp cfe_sgp

cfe_sgp represents a scheme for quadratic multi-variate polynomials based on Sans, Gay and Pointcheval: "Reading in the Dark: Classifying Encrypted Digits with Functional Encryption", see https://eprint.iacr.org/2018/206.pdf.

◆ cfe_sgp_sec_key

cfe_sgp_sec_key represents a secret key for SGP scheme.

◆ cfe_sgp_cipher

cfe_sgp_sec_key represents a ciphertext in SGP scheme.

Function Documentation

◆ cfe_sgp_init()

cfe_error cfe_sgp_init ( cfe_sgp s,
size_t  l,
mpz_t  bound 
)

Configures a new instance of the scheme.

Parameters
sA pointer to an uninitialized struct representing the scheme
lThe length of input vectors
boundThe bound by which coordinates of the encryption vectors and matrix for quadratic polynomial are bounded
Returns
Error code

◆ cfe_sgp_free()

void cfe_sgp_free ( cfe_sgp 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_sgp struct)

◆ cfe_sgp_sec_key_init()

void cfe_sgp_sec_key_init ( cfe_sgp_sec_key msk,
cfe_sgp sgp 
)

Initializes the struct which represents the master secret key.

Parameters
mskA pointer to an uninitialized secret key
sgpA pointer to an instance of the scheme (initialized cfe_sgp struct)

◆ cfe_sgp_sec_key_free()

void cfe_sgp_sec_key_free ( cfe_sgp_sec_key msk)

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

Parameters
mskA pointer to an instance of the secret key (initialized cfe_sgp_sec_key struct)

◆ cfe_sgp_generate_sec_key()

void cfe_sgp_generate_sec_key ( cfe_sgp_sec_key msk,
cfe_sgp s 
)

Generates a private secret key for the scheme.

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

◆ cfe_sgp_derive_fe_key()

cfe_error cfe_sgp_derive_fe_key ( ECP2_BN254 *  key,
cfe_sgp sgp,
cfe_sgp_sec_key msk,
cfe_mat f 
)

Takes master secret key and a matrix, and returns the corresponding functional encryption key.

Parameters
keyA pointer to a ECP2_BN254 struct (the functional encryption key will be stored here)
sgpA pointer to an instance of the scheme (initialized cfe_sgp struct)
mskA pointer to the master secret key
fA pointer to the matrix for the quadratic polynomial
Returns
Error code

◆ cfe_sgp_cipher_init()

void cfe_sgp_cipher_init ( cfe_sgp_cipher cipher,
cfe_sgp s 
)

Initializes the struct which represents the ciphertext.

Parameters
cipherA pointer to an uninitialized ciphertext struct
sA pointer to an instance of the scheme (initialized cfe_sgp struct)

◆ cfe_sgp_cipher_free()

void cfe_sgp_cipher_free ( cfe_sgp_cipher cipher)

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

Parameters
cipherA pointer to an instance of the ciphertext (initialized cfe_sgp_cipher struct)

◆ cfe_sgp_encrypt()

cfe_error cfe_sgp_encrypt ( cfe_sgp_cipher cipher,
cfe_sgp s,
cfe_vec x,
cfe_vec y,
cfe_sgp_sec_key msk 
)

Encrypts input vectors x and y with the provided master secret key.

Parameters
cipherA pointer to a vector (the resulting ciphertext will be stored here)
sA pointer to an instance of the scheme (initialized cfe_sgp struct)
xA pointer to the input vector
yA pointer to the input vector
mskA pointer to a master secret key.
Returns
Error code

◆ cfe_sgp_decrypt()

cfe_error cfe_sgp_decrypt ( mpz_t  res,
cfe_sgp s,
cfe_sgp_cipher cipher,
ECP2_BN254 *  key,
cfe_mat f 
)

Based on the encryption, functional encryption key, and a matrix, it returns the value of the quadratic polynomial. 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_sgp struct)
cipherA pointer to the ciphertext
keyA pointer to the functional encryption key
fA pointer to the matrix of the quadratic polynomial
Returns
Error code