本文整理汇总了Python中charm.toolbox.pairinggroup.PairingGroup.debug方法的典型用法代码示例。如果您正苦于以下问题:Python PairingGroup.debug方法的具体用法?Python PairingGroup.debug怎么用?Python PairingGroup.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charm.toolbox.pairinggroup.PairingGroup
的用法示例。
在下文中一共展示了PairingGroup.debug方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main():
groupObj = PairingGroup('SS512')
dabe = Dabe(groupObj)
GP = dabe.setup()
#Setup an authority
auth_attrs= ['ONE', 'TWO', 'THREE', 'FOUR']
(SK, PK) = dabe.authsetup(GP, auth_attrs)
if debug: print("Authority SK")
if debug: print(SK)
#Setup a user and give him some keys
gid, K = "bob", {}
usr_attrs = ['THREE', 'ONE', 'TWO']
for i in usr_attrs: dabe.keygen(GP, SK, i, gid, K)
if debug: print('User credential list: %s' % usr_attrs)
if debug: print("\nSecret key:")
if debug: groupObj.debug(K)
#Encrypt a random element in GT
m = groupObj.random(GT)
policy = '((one or three) and (TWO or FOUR))'
if debug: print('Acces Policy: %s' % policy)
CT = dabe.encrypt(PK, GP, m, policy)
if debug: print("\nCiphertext...")
if debug: groupObj.debug(CT)
orig_m = dabe.decrypt(GP, K, CT)
assert m == orig_m, 'FAILED Decryption!!!'
if debug: print('Successful Decryption!')
示例2: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main():
#Get the eliptic curve with the bilinear mapping feature needed.
groupObj = PairingGroup('SS512')
cpabe = CPabe09(groupObj)
(msk, pk) = cpabe.setup()
pol = '((ONE or THREE) and (TWO or FOUR))'
attr_list = ['THREE', 'ONE', 'TWO']
if debug: print('Acces Policy: %s' % pol)
if debug: print('User credential list: %s' % attr_list)
m = groupObj.random(GT)
cpkey = cpabe.keygen(pk, msk, attr_list)
if debug: print("\nSecret key: %s" % attr_list)
if debug:groupObj.debug(cpkey)
cipher = cpabe.encrypt(pk, m, pol)
if debug: print("\nCiphertext...")
if debug:groupObj.debug(cipher)
orig_m = cpabe.decrypt(pk, cpkey, cipher)
assert m == orig_m, 'FAILED Decryption!!!'
if debug: print('Successful Decryption!')
del groupObj
示例3: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main():
groupObj = PairingGroup('SS512')
cpabe = CPabe_BSW07(groupObj)
attrs = ['ONE', 'TWO', 'THREE']
access_policy = '((four or three) and (three or one))'
if debug:
print("Attributes =>", attrs); print("Policy =>", access_policy)
(pk, mk) = cpabe.setup()
sk = cpabe.keygen(pk, mk, attrs)
print("sk :=>", sk)
rand_msg = groupObj.random(GT)
if debug: print("msg =>", rand_msg)
ct = cpabe.encrypt(pk, rand_msg, access_policy)
if debug: print("\n\nCiphertext...\n")
groupObj.debug(ct)
rec_msg = cpabe.decrypt(pk, sk, ct)
if debug: print("\n\nDecrypt...\n")
if debug: print("Rec msg =>", rec_msg)
assert rand_msg == rec_msg, "FAILED Decryption: message is incorrect"
if debug: print("Successful Decryption!!!")
示例4: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main(num=5):
pol = generatePolicy(num)
attr_list = generateAttrList(num)
#Get the eliptic curve with the bilinear mapping feature needed.
groupObj = PairingGroup('SS512')
cpabe = RW13(groupObj)
(msk, pk) = cpabe.setup()
if debug: print('Acces Policy: %s' % pol)
if debug: print('User credential list: %s' % attr_list)
m = groupObj.random(GT)
cpkey = cpabe.keygen(pk, msk, attr_list)
if debug: print("\nSecret key: %s" % attr_list)
if debug:groupObj.debug(cpkey)
cipher = cpabe.encrypt(pk, m, pol)
if debug: print("\nCiphertext...")
if debug:groupObj.debug(cipher)
orig_m = cpabe.decrypt(pk, cpkey, cipher)
assert m == orig_m, 'FAILED Decryption!!!'
if debug: print('Successful Decryption!')
del groupObj
示例5: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main():
global group
group = PairingGroup(secparam)
userFuncs2.groupObj = group
builtInFuncs.util = SecretUtil(group, verbose=False)
attrs = ['ONE', 'TWO', 'THREE']
access_policy = '((four or three) and (two or one))'
print("Attributes =>", attrs); print("Policy =>", access_policy)
(mk, pk) = setup()
sk = keygen(pk, mk, attrs)
print("sk :=>", sk)
rand_msg = group.random(GT)
print("msg =>", rand_msg)
ct = encrypt(pk, rand_msg, access_policy)
print("\nCiphertext...\n")
group.debug(ct)
rec_msg = decrypt(pk, sk, ct)
print("\nDecrypt...\n")
print("Rec msg =>", rec_msg)
assert rand_msg == rec_msg, "FAILED Decryption: message is incorrect"
print("Successful Decryption!!!")
示例6: main
# 需要导入模块: from charm.toolbox.pairinggroup import PairingGroup [as 别名]
# 或者: from charm.toolbox.pairinggroup.PairingGroup import debug [as 别名]
def main():
global group
group = PairingGroup("SS512")
attrs = ["ONE", "TWO", "THREE"]
access_policy = "((four or three) and (two or one))"
# print("Attributes =>", attrs); print("Policy =>", access_policy)
(mk, pk) = setup()
sk = keygen(pk, mk, attrs)
# print("sk :=>", sk)
rand_msg = group.random(GT)
print("msg =>", rand_msg)
ct = encrypt(pk, rand_msg, access_policy)
# print("\n\nCiphertext...\n")
group.debug(ct)
rec_msg = decrypt(pk, sk, ct)
# print("\n\nDecrypt...\n")
print("Rec msg =>", rec_msg)
assert rand_msg == rec_msg, "FAILED Decryption: message is incorrect"
print("Successful Decryption!!!")