def encrypt(M, policy_str):
    global Y
    global attrs
    global sh
    global share
    global Cr
    global Cpr

    input = [pk, M, policy_str]
    g, g2, h, f, egg = pk
    policy = createPolicy(policy_str)
    attrs = getAttributeList(policy)
    R = groupObj.random(GT)
    s = groupObj.hash([R, M], ZR)
    s_sesskey = SHA1(R)
    Ctl = (R * (egg**s))
    sh = calculateSharesDict(s, policy)
    Y = len(sh)
    C = (h**s)
    for y in range(0, Y):
        y1 = attrs[y]
        share[y1] = sh[y1]
        Cr[y1] = (g**share[y1])
        Cpr[y1] = (groupObj.hash(y1, G2)**share[y1])
    T1 = SymEnc(s_sesskey, M)
    ct = [policy_str, Ctl, C, Cr, Cpr, T1]
    output = ct
    return output
def encrypt(M, id):
    global C
    global ct

    input = [mpk, M, id]
    g, gb, ga1, ga2, gba1, gba2, tau1, tau2, tau1b, tau2b, w, u, h, egga = mpk
    s1 = groupObj.random(ZR)
    R = groupObj.random(GT)
    s2 = groupObj.hash([R, M], ZR)
    s2_sesskey = SHA1(R)
    C[0] = (R * (egga**s2))
    t = groupObj.random(ZR)
    tag_c = groupObj.random(ZR)
    s = (s1 + s2)
    id_hash2 = groupObj.hash(id, ZR)
    C[1] = (gb**s)
    C[2] = (gba1**s1)
    C[3] = (ga1**s1)
    C[4] = (gba2**s2)
    C[5] = (ga2**s2)
    C[6] = ((tau1**s1) * (tau2**s2))
    C[7] = (((tau1b**s1) * (tau2b**s2)) * (w**-t))
    E1 = ((((u**id_hash2) * (w**tag_c)) * h)**t)
    E2 = (g**t)
    T1 = SymEnc(s2_sesskey, M)
    ct = [C, E1, E2, tag_c, T1]
    output = ct
示例#3
0
def decout(partCT, zz, egg):
    input = [partCT, zz, egg]
    T0, T1, T2 = partCT
    R = (T0 / (T2**zz))
    s_sesskey = SHA1(R)
    M = SymDec(s_sesskey, T1)
    s = groupObj.hash([R, M], ZR)
    output = M
    return output
示例#4
0
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
def decout(partCT, zz, egga):
	input = [partCT, zz, egga]
	T0, T1, T2 = partCT
	R = (T0 / (T2 ** zz))
	s2_sesskey = SHA1(R)
	M = SymDec(s2_sesskey, T1)
	s2 = groupObj.hash([R, M], ZR)
	if ( ( (( (T0) == ((R * (egga ** s2))) )) and (( (T2) == ((R * (egga ** (s2 / zz)))) )) ) ):
		output = M
	else:
		userErrorFunction('invalid ciphertext')
		return
	return output
示例#6
0
def decout(partCT, zz):
    input = [partCT, zz, egga]
    T0, T1, T2 = partCT
    R = (T0 / (T2**zz))
    s2_sesskey = SHA1(R)
    M = SymDec(s2_sesskey, T1)
    print("The message decrypts in decout to:  ", M)
    s2 = groupObj.hash([R, M], ZR)
    if (((((T0) == ((R * (egga**s2)))))
         and (((T2) == ((R * (egga**(s2 / zz)))))))):
        output = M
        print("RCCA check is successful")
    else:
        output = M
        print("RCCA check has failed.")
    return output