def main(): groupObj = PairingGroup('/Users/matt/Documents/charm/param/d224.param') hess = Hess(groupObj) chch = CHCH(groupObj) (mpk, msk) = chch.setup() _id = "*****@*****.**" (pk, sk) = chch.keygen(msk, _id) if debug: print("Keygen...") print("pk =>", pk) print("sk =>", sk) M = "this is a message! twice!" sig1 = hess.sign(mpk, sk, M) sig2 = chch.sign(pk, sk, M) sig = {'sig_hess': sig1, 'sig_chch': sig2} if debug: print("Signature...") print("sig1 =>", sig1) print("sig2 =>", sig2) assert verify(mpk, pk, M, sig, hess, chch), "invalid signature!" if debug: print("Verification successful!")
def getUserGlobals(): global groupObjUserFuncs, util if (groupObjUserFuncs == None): groupObjUserFuncs = PairingGroup('SS512') if (util == None): util = SecretUtil(groupObjUserFuncs, verbose=False)
def main(): groupObj = PairingGroup('../param/a.param') cpabe = CPabe_BSW07(groupObj) hyb_abe = HybridABEnc(cpabe, groupObj) access_policy = '((four or three) and (two or one))' message = "hello world this is an important message." if debug: print("Policy =>", access_policy) (pk, mk) = hyb_abe.setup() sk = hyb_abe.keygen(pk, mk, ['ONE', 'TWO', 'THREE']) ct = hyb_abe.encrypt(pk, message, access_policy) if debug: print("\nCiphertext: ", ct) rec_msg = hyb_abe.decrypt(pk, sk, ct) if debug: print("\n\nDecrypt...\n") if debug: print("Rec msg =>", rec_msg) assert message == rec_msg, "FAILED Decryption: message is incorrect" if debug: print("Successful Decryption!!!")
from userFuncs_BSW import * from toolbox.pairinggroup import PairingGroup, ZR, G1, G2, GT, pair from toolbox.secretutil import SecretUtil from toolbox.symcrypto import AuthenticatedCryptoAbstraction from toolbox.iterate import dotprod2 from charm.pairing import hash as SHA1 def decout(partCT, zz, egg): input = [partCT, zz, egg] T0, T1, T2 = partCT R = (T0 / (T2**zz)) s_sesskey = DeriveKey(R) M = SymDec(s_sesskey, T1) s = groupObj.hash([R, M], ZR) if (((((T0) == ((R * (egg**s))))) and (((T2) == ((egg**(s / zz))))))): output = M else: userErrorFunction('invalid ciphertext') return return output if __name__ == "__main__": global groupObj groupObj = PairingGroup('SS512') (M) = decout(sys.argv[1], sys.argv[2], sys.argv[3])
print('Trapdoor: %s for word: %s' % (self.group.hash(word, G1)**self.priv, word)) return self.group.hash(word, G1)**self.priv ''' Test(A_pub,S,T_W): When the messaging server receives a Test function from the legal authority as S=[A,B] it can test if H_2 (e(T_w,A))=B''' def Test(self, s, tw): a, b = s print(self.h1.hashToZn(str(pair(tw, a)))) print(b) return self.h1.hashToZn(str(pair(tw, a))) == self.h1.hashToZn(str(b)) if __name__ == '__main__': group = PairingGroup('SS512') KEYWORD1 = "fishing" KEYWORD2 = "banana" time1 = time.time() pClient = PKS(group) time2 = time.time() print('%s function took %0.3f ms' % ("Initiating Pairing Groups", (time2 - time1) * 1000)) time3 = time.time() pubKey = pClient.KeyGen() time4 = time.time() print('%s function took %0.3f ms' % ("Generating Keys", (time4 - time3) * 1000))
def __init__(self, secret): self.k = 3 self.n = 4 self.group = PairingGroup('SS512') self.s = SecretShare(self.group, False) self.sec = secret
def getUserGlobals(): global groupObjUserFuncs if (groupObjUserFuncs == None): groupObjUserFuncs = PairingGroup('SS512')
def decout(partCT, zz): T0, T1, T2 = partCT['T0'], partCT['T1'], partCT['T2'] R = (T0 / (T2**zz)) print("Recov R :=", R) s_sesskey = SHA1(R) M = SymDec(s_sesskey, T1) s = groupObj.hash([R, M], ZR) output = M return output if __name__ == "__main__": global groupObj groupObj = PairingGroup(MNT160) S = ['ONE', 'TWO', 'THREE'] M = "balls on fire123" policy_str = '((four or three) and (two or one))' setup() (zz, skBlinded) = keygen(['ONE', 'TWO', 'THREE']) (ct) = encrypt(M, policy_str) (partCT) = transform(ct) writeToFile('partCT.txt', objectOut(groupObj, partCT)) keys = {'sk': zz, 'pk': egg} writeToFile('keys.txt', objectOut(groupObj, keys)) M = decout(partCT, zz)