-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkpabe.h
95 lines (73 loc) · 2.61 KB
/
kpabe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef DEF_UTILS
#include "utils.h"
#endif
#ifndef DEF_SECRET_SHARING
#include "secretsharing.h"
#endif
#ifndef DEF_BL_CANON
#include "BLcanonical.h"
#endif
#define DEF_KPABE
#include "atts.h"
class KPABE {
shared_ptr<SecretSharing> m_scheme;
PFC& m_pfc;
unsigned int m_nAttr;
Big m_privateKeyRand;
Big m_lastCTRandomness;
Big m_order;
vector<Big> m_privateAttributes;
#ifdef AttOnG1_KeyOnG2
vector<G1> m_publicAtts;
#endif
#ifdef AttOnG2_KeyOnG1
vector<G2> m_publicAtts;
#endif
G1 m_P;
G2 m_Q;
GT m_publicCTBlinder;
#ifdef AttOnG1_KeyOnG2
vector<G2> makeKeyFrags(std::vector<ShareTuple> shares);
bool encrypt_main_body(const vector<int> &atts, vector<G1>& attFrags, GT& blinder);
bool decrypt_main_body(vector<G2> keyFrags, const vector<int>& atts, vector<G1>& attFrags, GT& blinder);
#endif
#ifdef AttOnG2_KeyOnG1
vector<G1> makeKeyFrags(std::vector<ShareTuple> shares);
bool encrypt_main_body(const vector<int> &atts, vector<G2>& attFrags, GT& blinder);
bool decrypt_main_body(vector<G1> keyFrags, const vector<int>& atts, vector<G2>& attFrags, GT& blinder);
#endif
public:
KPABE(PFC &pfc, int nAttr);
KPABE(shared_ptr<SecretSharing> scheme, PFC &pfc, int nAttr);
void paramsgen(G1& P, G2& Q, Big& order);
unsigned int numberAttr() const;
void setup();
vector<Big>& getPrivateAttributes() ;
Big& getPrivateKeyRand() ;
Big& getLastEncryptionRandomness() ;
GT& getPublicCTBlinder() ;
inline shared_ptr<SecretSharing> getScheme() {
return m_scheme;
}
inline shared_ptr<AccessPolicy> getPolicy() {
return m_scheme->getPolicy();
}
#ifdef AttOnG1_KeyOnG2
vector<G1>& getPublicAttributes() ;
vector<G2> genKey();
vector<G2> genKey(vector<Big> randomness);
bool encrypt(const vector<int> &atts, const GT& M, GT& CT, vector<G1>& attFrags);
bool encryptS(const vector<int> &atts, const Big& M, Big& CT, vector<G1>& attFrags);
bool decrypt(vector<G2> keyFrags, const vector<int>& atts, const GT& CT, vector<G1>& attFrags, GT& PT);
bool decryptS(vector<G2> keyFrags, const vector<int>& atts, const Big& CT, vector<G1>& attFrags, Big& PT);
#endif
#ifdef AttOnG2_KeyOnG1
vector<G2>& getPublicAttributes() ;
vector<G1> genKey();
vector<G1> genKey(vector<Big> randomness);
bool encrypt(const vector<int> &atts, const GT& M, GT& CT, vector<G2>& attFrags);
bool encryptS(const vector<int> &atts, const Big& M, Big& CT, vector<G2>& attFrags);
bool decrypt(vector<G1> keyFrags, const vector<int>& atts, const GT& CT, vector<G2>& attFrags, GT& PT);
bool decryptS(vector<G1> keyFrags, const vector<int>& atts, const Big& CT, vector<G2>& attFrags, Big& PT);
#endif
};