CiFEr
gpsw.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_GPSW_H
18 #define CIFER_GPSW_H
19 
20 #include <gmp.h>
21 #include <amcl/fp12_BN254.h>
22 
23 #include "cifer/data/vec_curve.h"
24 #include "cifer/data/vec.h"
25 #include "cifer/abe/policy.h"
26 #include "cifer/internal/errors.h"
27 
47 typedef struct cfe_gpsw {
48  size_t l;
49  mpz_t p;
50 } cfe_gpsw;
51 
55 typedef struct cfe_gpsw_pub_key {
56  cfe_vec_G2 t;
57  FP12_BN254 y;
59 
63 typedef struct cfe_gpsw_cipher {
64  int *gamma;
65  FP12_BN254 e0;
66  cfe_vec_G2 e;
68 
73 typedef struct cfe_gpsw_key {
74  cfe_vec_G1 d;
75  cfe_msp msp;
76 } cfe_gpsw_key;
77 
84 void cfe_gpsw_init(cfe_gpsw *gpsw, size_t l);
85 
94 
104 
111 void cfe_gpsw_cipher_init(cfe_gpsw_cipher *cipher, size_t num_attrib);
112 
113 // TODO: change message to be a string when mapping is defined
127 void cfe_gpsw_encrypt(cfe_gpsw_cipher *cipher, cfe_gpsw *gpsw, FP12_BN254 *msg,
128  int *gamma, size_t num_attrib, cfe_gpsw_pub_key *pk);
129 
137 void cfe_gpsw_key_init(cfe_gpsw_key *policy_key, cfe_msp *msp);
138 
153 
157 void cfe_gpsw_rand_vec_const_sum(cfe_vec *v, mpz_t y, mpz_t p);
158 
159 // TODO: change decryption to be a string when mapping is defined
173 cfe_error cfe_gpsw_decrypt(FP12_BN254 *res, cfe_gpsw_cipher *cipher, cfe_gpsw_key *key, cfe_gpsw *gpsw);
174 
182 void cfe_gpsw_free(cfe_gpsw *gpsw);
183 
192 
201 
210 
211 #endif
cfe_vec_G1
Definition: vec_curve.h:34
policy.h
Functions for policy conversion needed for ABE schemes.
cfe_gpsw_init
void cfe_gpsw_init(cfe_gpsw *gpsw, size_t l)
cfe_gpsw_cipher_init
void cfe_gpsw_cipher_init(cfe_gpsw_cipher *cipher, size_t num_attrib)
cfe_gpsw_key
Definition: gpsw.h:73
cfe_vec
Definition: vec.h:41
cfe_gpsw_generate_master_keys
void cfe_gpsw_generate_master_keys(cfe_gpsw_pub_key *pk, cfe_vec *sk, cfe_gpsw *gpsw)
cfe_gpsw_free
void cfe_gpsw_free(cfe_gpsw *gpsw)
cfe_gpsw_key
struct cfe_gpsw_key cfe_gpsw_key
errors.h
Error definitions.
cfe_gpsw_decrypt
cfe_error cfe_gpsw_decrypt(FP12_BN254 *res, cfe_gpsw_cipher *cipher, cfe_gpsw_key *key, cfe_gpsw *gpsw)
cfe_gpsw
Definition: gpsw.h:47
vec_curve.h
Vectors of elements of an elliptic curve struct and operations on it.
cfe_gpsw_pub_key
struct cfe_gpsw_pub_key cfe_gpsw_pub_key
cfe_gpsw_pub_key
Definition: gpsw.h:55
cfe_msp
Definition: policy.h:43
cfe_gpsw_cipher
Definition: gpsw.h:63
cfe_gpsw_key_init
void cfe_gpsw_key_init(cfe_gpsw_key *policy_key, cfe_msp *msp)
cfe_gpsw_master_keys_init
void cfe_gpsw_master_keys_init(cfe_gpsw_pub_key *pk, cfe_vec *sk, cfe_gpsw *gpsw)
cfe_gpsw_cipher_free
void cfe_gpsw_cipher_free(cfe_gpsw_cipher *cipher)
cfe_gpsw_generate_policy_key
void cfe_gpsw_generate_policy_key(cfe_gpsw_key *key, cfe_gpsw *gpsw, cfe_msp *msp, cfe_vec *sk)
cfe_gpsw_key_free
void cfe_gpsw_key_free(cfe_gpsw_key *key)
vec.h
Vector struct and operations.
cfe_gpsw
struct cfe_gpsw cfe_gpsw
cfe_vec_G2
Definition: vec_curve.h:42
cfe_gpsw_cipher
struct cfe_gpsw_cipher cfe_gpsw_cipher
cfe_gpsw_encrypt
void cfe_gpsw_encrypt(cfe_gpsw_cipher *cipher, cfe_gpsw *gpsw, FP12_BN254 *msg, int *gamma, size_t num_attrib, cfe_gpsw_pub_key *pk)
cfe_gpsw_rand_vec_const_sum
void cfe_gpsw_rand_vec_const_sum(cfe_vec *v, mpz_t y, mpz_t p)
cfe_gpsw_pub_key_free
void cfe_gpsw_pub_key_free(cfe_gpsw_pub_key *pk)