forked from aietxm/KPABEwithNon-monotonic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abe-de.py
31 lines (18 loc) · 740 Bytes
/
abe-de.py
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
from charm.toolbox.pairinggroup import PairingGroup,GT
from charm.core.math.pairing import hashPair as sha1
from charm.schemes.abenc.abenc_waters09 import CPabe09
from charm.toolbox.symcrypto import SymmetricCryptoAbstraction,AuthenticatedCryptoAbstraction, MessageAuthenticator
asl= ['ONE','TWO']
groupObj = PairingGroup('SS512')
cpabe = CPabe09(groupObj)
with open('/Users/cirnotxm/down/info','rb') as f:
info = f.read()
cpkey = cpabe.keygen(pk,msk,asl)
with open('/Users/cirnotxm/down/cipk','r') as f2:
ciphertext = f2.read()
ciphertext = eval(ciphertext)
print ciphertext
prig_msg = cpabe.decrypt(pk,cpkey,ciphertext)
a2 = SymmetricCryptoAbstraction(sha1(orig_symKey))
plaintext = a2.decrypt(info)
print plaintext