当前位置: 首页>>代码示例>>Python>>正文


Python pairinggroup.PairingGroup类代码示例

本文整理汇总了Python中charm.toolbox.pairinggroup.PairingGroup的典型用法代码示例。如果您正苦于以下问题:Python PairingGroup类的具体用法?Python PairingGroup怎么用?Python PairingGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PairingGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

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!!!")
开发者ID:FinalF,项目名称:charm,代码行数:26,代码来源:abenc_bsw07.py

示例2: main

def main():
    global group
    group = PairingGroup(secparam)

    alphabet = ['a', 'b']
    dfa = DFA("ab*a", alphabet)
    builtinFuncs_dfa.DFAObj = dfa
    dfaM = dfa.constructDFA()

    (mpk, msk) = setup(alphabet)

    (blindingFactor0Blinded, skBlinded) = keygen(mpk, msk, dfaM)
    w = dfa.getSymbols("abba")
    M = group.random(GT)
    print("M :", M)
    ct = encrypt(mpk, w, M)

    transformOutputList = transform(skBlinded, ct)
    origM = decout(skBlinded, ct, transformOutputList, blindingFactor0Blinded, blindingFactorKendList1Blinded)



    print("rec M :", origM)
    assert M == origM, "failed decryption"
    print("SUCCESSFUL DECRYPTION!!!") 
开发者ID:JHUISI,项目名称:auto-tools,代码行数:25,代码来源:dfa.py

示例3: main

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!!!")
开发者ID:JHUISI,项目名称:auto-tools,代码行数:28,代码来源:bsw07_asym_ky.py

示例4: main

def main():
    global group
    #group = PairingGroup(secparam)
    group = PairingGroup("SS512")

    alphabet = ['a', 'b']
    dfa = DFA("ab*a", alphabet)
    builtinFuncs_dfa.DFAObj = dfa
    dfaM = dfa.constructDFA()

    (mpk, msk) = setup(alphabet)

    Q, S, T, q0, F = dfaM

    (blindingFactor0Blinded, skBlinded) = keygen(mpk, msk, Q, T, F)
    w = dfa.getSymbols("abbba")
    M = group.random(GT)
    print("M :", M)
    ct = encrypt(mpk, w, M)

    (transformOutputList, l, Ti, transformOutputListForLoop) = transform(skBlinded, ct, dfaM)
    origM = decout(dfaM, transformOutputList, blindingFactor0Blinded, l, Ti, transformOutputListForLoop)


    print("rec M :", origM)
    assert M == origM, "failed decryption"
    print("SUCCESSFUL DECRYPTION!!!") 
开发者ID:JHUISI,项目名称:auto-tools,代码行数:27,代码来源:forAyoDFA.py

示例5: main

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!!!")
开发者ID:JHUISI,项目名称:auto-tools,代码行数:25,代码来源:bsw.py

示例6: main

def main():
    global group
    group = PairingGroup("SS512")

    alphabet = {'a', 'b'}
    dfa = DFA("ab*a", alphabet)
    dfaM = dfa.constructDFA()

    fe = FE_DFA(group, dfa)

    (mpk, msk) = fe.setup(alphabet)
    if debug: print("mpk :=>", mpk, "\n\n")

    sk = fe.keygen(mpk, msk, dfaM)
    if debug: print("sk :=>", sk)

    w = dfa.getSymbols("abba")
    w1 = dfa.getSymbols("aba")
    M = group.random(GT)
    ct = fe.encrypt(mpk, w, M)

    # Explicitly override the string with another valid string
    ct[1] = w1
    print w1 == w

    origM = fe.decrypt(sk, ct)
    assert M == origM, "failed decryption!"
    if debug: print("Successful Decryption!!!!!")
开发者ID:chris-wood,项目名称:dfa-fe,代码行数:28,代码来源:dfa_fe12.py

示例7: main

def main():
	global benchmarkResult, options

	options=parse_args()

	# SS512 : a symmertic curve with a 512-bit base field
	# MNT159 : an asymmetric curve with a 159-bit based field
	groupObj = PairingGroup ('SS512')
	generator = groupObj.random(G1)
	# for optimization 
	assert generator.initPP(), "failed to init pre-computation table"

	# initialize key server and user objects
	ks = KS (groupObj, generator)
	user = User (groupObj, generator)

	# set up key server
	pk=ks.setup()

	if options.output_file is not None:
		rf=open(options.output_file, "w")
	else:
		rf=sys.stdout
	rf.write ("#KB\tN.KS\tN.kss\tD1\tD2\tHash\tSE\tGroup\tKS\tTo.\tTo.(CR)\tTo.(SE)\n")

	sys.stderr.write ("Run experiment...\n")

	if options.file_size > 0:
		file_size=[options.file_size]

	for fsize in file_size:
		# generate sample file
		create_file (sample_file, fsize)

		benchmarkResult={}
		for count in range (0,options.trials, 1):
			# compute a hash for a file
			h=user.computeHash(sample_file)

			# generate tag and decryption key
			t_F, dk_F = user.generate_key_and_tag(pk, h, ks)
		
			# encrypt a file
			C1,C2,C3=user.encrypt (t_F,pk,sample_file,h)


		delay_Hash=round(benchmarkResult['Hash']*1000/options.trials,2)
		delay_SE=round(benchmarkResult['SE']*1000/options.trials,2)
		delay_Group=round(benchmarkResult['Group']*1000/options.trials,2)
		delay_KS=round(benchmarkResult['KS']*1000/options.trials,2)
		delay_total=round(delay_Hash+delay_SE+delay_Group+delay_KS,2)
		delay_total_cr=round(delay_Hash+delay_Group+delay_KS,2)
		delay_total_SE=delay_SE

		rf.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}\n".format(\
			int(fsize/1024), options.num_of_KS, options.num_of_kss, options.KS_delay1, options.KS_delay2,\
			delay_Hash, delay_SE, delay_Group, delay_KS,delay_total,delay_total_cr,delay_total_SE))
			
	rf.close()
开发者ID:syoungjoo,项目名称:fogpaper,代码行数:59,代码来源:proposed.py

示例8: testPairingGroup

    def testPairingGroup(self):    
        groupobj = PairingGroup('SS512')
        p=groupobj.random()
        data={'p':p,'String':"foo",'list':[p,{},1,1.7, b'dfa',]}

        x=objectToBytes(data,groupobj)
        data2=bytesToObject(x,groupobj)
        self.assertEqual(data,data2)
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:8,代码来源:serialize_test.py

示例9: MsgTestAESCBCSeperate

 def MsgTestAESCBCSeperate(self,msg):
     groupObj = PairingGroup('SS512')
     ran = groupObj.random(GT)
     a =  AuthenticatedCryptoAbstraction(sha1(ran))
     ct = a.encrypt(msg)        
     b =  AuthenticatedCryptoAbstraction(sha1(ran))
     dmsg = b.decrypt(ct);
     assert msg == dmsg , 'o: =>%s\nm: =>%s' % (msg, dmsg)
开发者ID:FinalF,项目名称:charm,代码行数:8,代码来源:symcrypto_test.py

示例10: main

def main():

    group = PairingGroup('MNT224', secparam=1024)    
    ibe = IBE_Chen12_z(group)
    (master_public_key, master_secret_key) = ibe.setup()
    ID = '[email protected]'
    private_key = ibe.extract(master_secret_key, ID)
    msg = group.random(GT)
    cipher_text = ibe.encrypt(master_public_key, ID, msg)
    decryptedMSG = ibe.decrypt(master_public_key, private_key, cipher_text)
    print (decryptedMSG==msg)
开发者ID:zfwise,项目名称:myCharmCode,代码行数:11,代码来源:ibenc_cllww12_z.py

示例11: CPABE

def CPABE():
    group = PairingGroup('SS512')
    cpabe = CPabe_BSW07(group)
    (pk,mk) = cpabe.setup()
    policy = 'ID1 or ID2 or ID3'
    asl =['ID1']
    msg = group.random(GT)
    ct = cpabe.encrypt(pk,msg,policy)
    sk = cpabe.keygen(pk,mk,asl)
    plaintext = cpabe.decrypt(pk,sk,ct)
    print plaintext
    print msg
开发者ID:aietxm,项目名称:Rbac-abe,代码行数:12,代码来源:racl_cpabe.py

示例12: main

def main():

    #group = PairingGroup('MNT159', secparam=1024)    
    G = PairingGroup('SS512')

    ibe = IBE_BB04_m(G)
    (master_public_key, master_secret_key) = ibe.setup()
    ID = '[email protected]'
    private_key = ibe.extract(master_secret_key, ID)
    msg = G.random(GT)
    cipher_text = ibe.encrypt(master_public_key, ID, msg)
    decryptedMSG = ibe.decrypt(master_public_key, private_key, cipher_text)
    print (decryptedMSG==msg)
开发者ID:zfwise,项目名称:myCharmCode,代码行数:13,代码来源:ibe_BB04_m.py

示例13: main

def main():
    group = PairingGroup('MNT224')
    waters_hash = Waters(group)
    ibe = IBE_N04_z(group)
    (master_public_key, master_key) = ibe.setup()

    ID = "[email protected]"
    secret_key = ibe.extract(master_key, ID)
    msg = group.random(GT)
    cipher_text = ibe.encrypt(master_public_key, ID, msg)
    decrypted_msg = ibe.decrypt(master_public_key, secret_key, cipher_text)
    assert msg == decrypted_msg, "invalid decryption"
    if debug: print("Successful Decryption!")
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:13,代码来源:ibenc_waters05_z.py

示例14: main

def main():
    global group
    group = PairingGroup(secparam)

    gpk = setup()
    (msk, pk) = authsetup(gpk, ['ONE', 'TWO', 'THREE', 'FOUR'])
    sk = keygen(gpk, msk, "[email protected]", ['ONE', 'TWO', 'THREE'])
    M = group.random(GT)
    ct = encrypt(pk, gpk, M, '((four or three) and (two or one))')
    M2 = decrypt(sk, ct)
    #'''
    print(M)
    print("\n\n\n")
    print(M2)
开发者ID:JHUISI,项目名称:auto-tools,代码行数:14,代码来源:lw10.py

示例15: testCommitment_GS08

 def testCommitment_GS08(self):
     groupObj = PairingGroup('SS512')
     cm = Commitment_GS08(groupObj)
    
     pk = cm.setup()
     if debug: 
         print("Public parameters...")
         print("pk =>", pk)
     
     m = groupObj.random(G1)
     if debug: print("Committing to =>", m)
     (c, d) = cm.commit(pk, m)
     
     assert cm.decommit(pk, c, d, m), "FAILED to decommit"
     if debug: print("Successful and Verified decommitment!!!")
开发者ID:FinalF,项目名称:charm,代码行数:15,代码来源:commit_test.py


注:本文中的charm.toolbox.pairinggroup.PairingGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。