CiFEr
dippe.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_DIPPE_H
18 #define CIFER_DIPPE_H
19 
20 #include <amcl/ecp2_BN254.h>
21 #include <amcl/fp12_BN254.h>
22 #include <gmp.h>
23 #include <stdlib.h>
24 
25 #include "cifer/data/mat.h"
26 #include "cifer/data/mat_curve.h"
27 #include "cifer/data/vec.h"
28 #include "cifer/data/vec_curve.h"
29 #include "cifer/internal/errors.h"
30 
42 typedef struct cfe_dippe {
43  size_t assump_size;
44  mpz_t p;
45  cfe_mat_G1 g1_A;
46  cfe_mat_G1 g1_UA;
47 } cfe_dippe;
48 
55 void cfe_dippe_init(cfe_dippe *dippe, size_t assump_size);
56 
62 void cfe_dippe_free(cfe_dippe *dippe);
63 
73 cfe_error cfe_dippe_attribute_vector_init(cfe_vec *av, size_t num_attrib, size_t pattern[], size_t pat_len);
74 
86 cfe_error
87 cfe_dippe_exact_threshold_policy_vector_init(cfe_vec *pv, cfe_dippe *dippe, size_t num_attrib, size_t pattern[],
88  size_t pat_len, size_t threshold);
89 
100 cfe_error cfe_dippe_conjunction_policy_vector_init(cfe_vec *pv, cfe_dippe *dippe, size_t num_attrib, size_t pattern[],
101  size_t pat_len);
102 
106 typedef struct cfe_dippe_cipher {
107  FP12_BN254 C_prime;
108  cfe_vec_G1 C0;
109  cfe_mat_G1 Ci;
111 
119 void cfe_dippe_cipher_init(cfe_dippe_cipher *cipher, cfe_dippe *dippe, size_t pol_size);
120 
127 
131 typedef struct cfe_dippe_pub_key {
132  ECP2_BN254 g2_sigma;
133  cfe_mat_G1 g1_W_A;
134  cfe_vec_GT gt_alpha_A;
136 
144 
151 
155 typedef struct cfe_dippe_sec_key {
156  mpz_t sigma;
157  cfe_vec alpha;
158  cfe_mat W;
160 
168 
175 
179 typedef struct cfe_dippe_user_sec_key {
180  cfe_vec_G2 Ki;
182 
190 
197 
206 
218 cfe_error
219 cfe_dippe_encrypt(cfe_dippe_cipher *cipher, cfe_dippe *dippe, cfe_dippe_pub_key *pks[], size_t pks_len, cfe_vec *pv,
220  FP12_BN254 *msg);
221 
236 cfe_error cfe_dippe_keygen(cfe_dippe_user_sec_key *usk, cfe_dippe *dippe, size_t usk_id,
237  cfe_dippe_pub_key *pks[], size_t pks_len, cfe_dippe_sec_key *sk,
238  cfe_vec *av, char *gid, size_t gid_len);
239 
252 cfe_error cfe_dippe_decrypt(FP12_BN254 *result, cfe_dippe *dippe, cfe_dippe_user_sec_key *usks,
253  size_t usks_len, cfe_dippe_cipher *cipher, cfe_vec *av,
254  char gid[], size_t gid_len);
255 
256 #endif
cfe_vec_G1
Definition: vec_curve.h:34
cfe_dippe_user_sec_key
Definition: dippe.h:179
cfe_dippe_cipher_free
void cfe_dippe_cipher_free(cfe_dippe_cipher *cipher)
cfe_dippe_cipher_init
void cfe_dippe_cipher_init(cfe_dippe_cipher *cipher, cfe_dippe *dippe, size_t pol_size)
cfe_dippe
struct cfe_dippe cfe_dippe
cfe_dippe_pub_key
Definition: dippe.h:131
cfe_dippe_pub_key_init
void cfe_dippe_pub_key_init(cfe_dippe_pub_key *pk, cfe_dippe *dippe)
cfe_vec
Definition: vec.h:41
cfe_mat_G1
Definition: mat_curve.h:33
cfe_dippe_conjunction_policy_vector_init
cfe_error cfe_dippe_conjunction_policy_vector_init(cfe_vec *pv, cfe_dippe *dippe, size_t num_attrib, size_t pattern[], size_t pat_len)
cfe_dippe_attribute_vector_init
cfe_error cfe_dippe_attribute_vector_init(cfe_vec *av, size_t num_attrib, size_t pattern[], size_t pat_len)
cfe_dippe_cipher
struct cfe_dippe_cipher cfe_dippe_cipher
cfe_dippe_generate_master_keys
void cfe_dippe_generate_master_keys(cfe_dippe_pub_key *pk, cfe_dippe_sec_key *sk, cfe_dippe *dippe)
mat.h
Matrix struct and operations.
cfe_dippe_sec_key_init
void cfe_dippe_sec_key_init(cfe_dippe_sec_key *sk, cfe_dippe *dippe)
errors.h
Error definitions.
cfe_dippe_user_sec_key_init
void cfe_dippe_user_sec_key_init(cfe_dippe_user_sec_key *usk, cfe_dippe *dippe)
vec_curve.h
Vectors of elements of an elliptic curve struct and operations on it.
cfe_dippe_decrypt
cfe_error cfe_dippe_decrypt(FP12_BN254 *result, cfe_dippe *dippe, cfe_dippe_user_sec_key *usks, size_t usks_len, cfe_dippe_cipher *cipher, cfe_vec *av, char gid[], size_t gid_len)
cfe_dippe_pub_key
struct cfe_dippe_pub_key cfe_dippe_pub_key
cfe_vec_GT
Definition: vec_curve.h:50
cfe_dippe
Definition: dippe.h:42
cfe_dippe_init
void cfe_dippe_init(cfe_dippe *dippe, size_t assump_size)
mat_curve.h
Matrices of elements of an elliptic curve struct and operations on it.
cfe_dippe_keygen
cfe_error cfe_dippe_keygen(cfe_dippe_user_sec_key *usk, cfe_dippe *dippe, size_t usk_id, cfe_dippe_pub_key *pks[], size_t pks_len, cfe_dippe_sec_key *sk, cfe_vec *av, char *gid, size_t gid_len)
cfe_dippe_exact_threshold_policy_vector_init
cfe_error cfe_dippe_exact_threshold_policy_vector_init(cfe_vec *pv, cfe_dippe *dippe, size_t num_attrib, size_t pattern[], size_t pat_len, size_t threshold)
cfe_dippe_sec_key
Definition: dippe.h:155
cfe_dippe_cipher
Definition: dippe.h:106
vec.h
Vector struct and operations.
cfe_dippe_sec_key_free
void cfe_dippe_sec_key_free(cfe_dippe_sec_key *sk)
cfe_vec_G2
Definition: vec_curve.h:42
cfe_dippe_sec_key
struct cfe_dippe_sec_key cfe_dippe_sec_key
cfe_dippe_pub_key_free
void cfe_dippe_pub_key_free(cfe_dippe_pub_key *pk)
cfe_dippe_user_sec_key_free
void cfe_dippe_user_sec_key_free(cfe_dippe_user_sec_key *usk)
cfe_dippe_user_sec_key
struct cfe_dippe_user_sec_key cfe_dippe_user_sec_key
cfe_dippe_encrypt
cfe_error cfe_dippe_encrypt(cfe_dippe_cipher *cipher, cfe_dippe *dippe, cfe_dippe_pub_key *pks[], size_t pks_len, cfe_vec *pv, FP12_BN254 *msg)
cfe_dippe_free
void cfe_dippe_free(cfe_dippe *dippe)
cfe_mat
Definition: mat.h:44