CiFEr
fhipe.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 XLAB d.o.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CIFER_FHIPE_H
18 #define CIFER_FHIPE_H
19 
20 #include "cifer/data/mat.h"
21 #include "cifer/data/vec_curve.h"
22 
38 typedef struct cfe_fhipe {
39  size_t l;
40  mpz_t bound_x;
41  mpz_t bound_y;
42  mpz_t order;
43 } cfe_fhipe;
44 
56 cfe_error cfe_fhipe_init(cfe_fhipe *c, size_t l, mpz_t bound_x, mpz_t bound_y);
57 
66 void cfe_fhipe_copy(cfe_fhipe *res, cfe_fhipe *c);
67 
75 void cfe_fhipe_free(cfe_fhipe *c);
76 
80 typedef struct cfe_fhipe_sec_key {
81  ECP_BN254 g1;
82  ECP2_BN254 g2;
83  cfe_mat B;
84  cfe_mat B_star;
86 
95 
103 
115 
119 typedef struct cfe_fhipe_fe_key {
120  ECP_BN254 k1;
121  cfe_vec_G1 k2;
123 
132 
140 
153 cfe_error cfe_fhipe_derive_fe_key(cfe_fhipe_fe_key *fe_key, cfe_vec *y,
154  cfe_fhipe_sec_key *sec_key, cfe_fhipe *c);
155 
159 typedef struct cfe_fhipe_ciphertext {
160  ECP2_BN254 c1;
161  cfe_vec_G2 c2;
163 
172 
180 
193 cfe_error cfe_fhipe_encrypt(cfe_fhipe_ciphertext *cipher, cfe_vec *x,
194  cfe_fhipe_sec_key *sec_key, cfe_fhipe *c);
195 
207 cfe_error cfe_fhipe_decrypt(mpz_t res, cfe_fhipe_ciphertext *cipher,
208  cfe_fhipe_fe_key *fe_key, cfe_fhipe *c);
209 
210 #endif
cfe_vec_G1
Definition: vec_curve.h:34
cfe_fhipe_derive_fe_key
cfe_error cfe_fhipe_derive_fe_key(cfe_fhipe_fe_key *fe_key, cfe_vec *y, cfe_fhipe_sec_key *sec_key, cfe_fhipe *c)
cfe_fhipe_ciphertext
Definition: fhipe.h:159
cfe_fhipe_sec_key
struct cfe_fhipe_sec_key cfe_fhipe_sec_key
cfe_fhipe_sec_key
Definition: fhipe.h:80
cfe_fhipe_fe_key
Definition: fhipe.h:119
cfe_vec
Definition: vec.h:41
cfe_fhipe_ciphertext
struct cfe_fhipe_ciphertext cfe_fhipe_ciphertext
cfe_fhipe_ciphertext_init
void cfe_fhipe_ciphertext_init(cfe_fhipe_ciphertext *cipher, cfe_fhipe *c)
cfe_fhipe_generate_master_key
cfe_error cfe_fhipe_generate_master_key(cfe_fhipe_sec_key *sec_key, cfe_fhipe *c)
cfe_fhipe_decrypt
cfe_error cfe_fhipe_decrypt(mpz_t res, cfe_fhipe_ciphertext *cipher, cfe_fhipe_fe_key *fe_key, cfe_fhipe *c)
cfe_fhipe_ciphertext_free
void cfe_fhipe_ciphertext_free(cfe_fhipe_ciphertext *cipher)
cfe_fhipe_fe_key_free
void cfe_fhipe_fe_key_free(cfe_fhipe_fe_key *fe_key)
mat.h
Matrix struct and operations.
cfe_fhipe_fe_key
struct cfe_fhipe_fe_key cfe_fhipe_fe_key
vec_curve.h
Vectors of elements of an elliptic curve struct and operations on it.
cfe_fhipe_copy
void cfe_fhipe_copy(cfe_fhipe *res, cfe_fhipe *c)
cfe_fhipe
Definition: fhipe.h:38
cfe_fhipe_master_key_free
void cfe_fhipe_master_key_free(cfe_fhipe_sec_key *sec_key)
cfe_fhipe_fe_key_init
void cfe_fhipe_fe_key_init(cfe_fhipe_fe_key *fe_key, cfe_fhipe *c)
cfe_fhipe_master_key_init
void cfe_fhipe_master_key_init(cfe_fhipe_sec_key *sec_key, cfe_fhipe *c)
cfe_vec_G2
Definition: vec_curve.h:42
cfe_fhipe_init
cfe_error cfe_fhipe_init(cfe_fhipe *c, size_t l, mpz_t bound_x, mpz_t bound_y)
cfe_fhipe_free
void cfe_fhipe_free(cfe_fhipe *c)
cfe_fhipe_encrypt
cfe_error cfe_fhipe_encrypt(cfe_fhipe_ciphertext *cipher, cfe_vec *x, cfe_fhipe_sec_key *sec_key, cfe_fhipe *c)
cfe_fhipe
struct cfe_fhipe cfe_fhipe
cfe_mat
Definition: mat.h:44