CiFEr
fame.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_FAME_H
18 #define CIFER_FAME_H
19 
20 #include <gmp.h>
21 #include <amcl/fp12_BN254.h>
22 #include <amcl/ecp_BN254.h>
23 #include <amcl/ecp2_BN254.h>
24 
25 #include "cifer/data/vec.h"
26 #include "cifer/abe/policy.h"
27 #include "cifer/internal/errors.h"
28 
46 typedef struct cfe_fame {
47  mpz_t p;
48 } cfe_fame;
49 
54 typedef struct cfe_fame_pub_key {
55  ECP2_BN254 part_G2[2];
56  FP12_BN254 part_GT[2];
58 
62 typedef struct cfe_fame_sec_key {
63  mpz_t part_int[4];
64  ECP_BN254 part_G1[3];
66 
70 typedef struct cfe_fame_cipher {
71  ECP2_BN254 ct0[3];
72  ECP_BN254 (*ct)[3];
73  FP12_BN254 ct_prime;
74  cfe_msp msp;
76 
81 typedef struct cfe_fame_attrib_keys {
82  ECP2_BN254 k0[3];
83  ECP_BN254 (*k)[3];
84  ECP_BN254 k_prime[3];
85  int *row_to_attrib;
86  size_t num_attrib;
88 
94 void cfe_fame_init(cfe_fame *fame);
95 
103 void cfe_fame_free(cfe_fame *fame);
104 
111 
120 
130  cfe_fame_sec_key *sk, cfe_fame *fame);
131 
140 void cfe_fame_cipher_init(cfe_fame_cipher *cipher, cfe_msp *msp);
141 
150 
151 // TODO: change message to be a string when mapping is defined
164 void cfe_fame_encrypt(cfe_fame_cipher *cipher, FP12_BN254 *msg,
165  cfe_msp *msp, cfe_fame_pub_key *pk, cfe_fame *fame);
166 
174 void cfe_fame_attrib_keys_init(cfe_fame_attrib_keys *keys, size_t num_attrib);
175 
184 
197  size_t num_attrib, cfe_fame_sec_key *sk, cfe_fame *fame);
198 
199 // TODO: change decryption to be a string when mapping is defined
213 cfe_error cfe_fame_decrypt(FP12_BN254 *res, cfe_fame_cipher *cipher,
214  cfe_fame_attrib_keys *keys, cfe_fame *fame);
215 
216 #endif
policy.h
Functions for policy conversion needed for ABE schemes.
cfe_fame_init
void cfe_fame_init(cfe_fame *fame)
cfe_fame_free
void cfe_fame_free(cfe_fame *fame)
cfe_fame
Definition: fame.h:46
cfe_fame_attrib_keys
Definition: fame.h:81
cfe_fame_sec_key_free
void cfe_fame_sec_key_free(cfe_fame_sec_key *sk)
cfe_fame_pub_key
Definition: fame.h:54
cfe_fame_sec_key
Definition: fame.h:62
cfe_fame_sec_key
struct cfe_fame_sec_key cfe_fame_sec_key
cfe_fame_attrib_keys_init
void cfe_fame_attrib_keys_init(cfe_fame_attrib_keys *keys, size_t num_attrib)
errors.h
Error definitions.
cfe_fame_cipher_free
void cfe_fame_cipher_free(cfe_fame_cipher *cipher)
cfe_fame_generate_attrib_keys
void cfe_fame_generate_attrib_keys(cfe_fame_attrib_keys *keys, int *gamma, size_t num_attrib, cfe_fame_sec_key *sk, cfe_fame *fame)
cfe_fame_generate_master_keys
void cfe_fame_generate_master_keys(cfe_fame_pub_key *pk, cfe_fame_sec_key *sk, cfe_fame *fame)
cfe_fame_pub_key
struct cfe_fame_pub_key cfe_fame_pub_key
cfe_fame_cipher
struct cfe_fame_cipher cfe_fame_cipher
cfe_fame_cipher_init
void cfe_fame_cipher_init(cfe_fame_cipher *cipher, cfe_msp *msp)
cfe_fame
struct cfe_fame cfe_fame
cfe_msp
Definition: policy.h:43
cfe_fame_encrypt
void cfe_fame_encrypt(cfe_fame_cipher *cipher, FP12_BN254 *msg, cfe_msp *msp, cfe_fame_pub_key *pk, cfe_fame *fame)
cfe_fame_attrib_keys_free
void cfe_fame_attrib_keys_free(cfe_fame_attrib_keys *keys)
cfe_fame_sec_key_init
void cfe_fame_sec_key_init(cfe_fame_sec_key *sk)
cfe_fame_attrib_keys
struct cfe_fame_attrib_keys cfe_fame_attrib_keys
vec.h
Vector struct and operations.
cfe_fame_decrypt
cfe_error cfe_fame_decrypt(FP12_BN254 *res, cfe_fame_cipher *cipher, cfe_fame_attrib_keys *keys, cfe_fame *fame)
cfe_fame_cipher
Definition: fame.h:70