Exemplo n.º 1
0
 def encrypt(self, mpk, ID, msg):
     s, s1, s2 = group.random(ZR, 3)
     hID = self.strToId(mpk, ID)
     hashID1 = mpk['g_l'][0] * dotprod2(range(1,mpk['n']), lam_func, mpk['g_l'], hID)
     c = {}
     c_pr = (mpk['omega'] ** s) * msg
     c[0] = hashID1 ** s
     c[1] = mpk['v1'] ** (s - s1)
     c[2] = mpk['v2'] ** s1
     c[3] = mpk['v3'] ** (s - s2)
     c[4] = mpk['v4'] ** s2        
     return {'c':c, 'c_prime':c_pr }
Exemplo n.º 2
0
 def extract(self, mpk, msk, ID):
     r1, r2 = group.random(ZR, 2) # should be params of extract
     hID = self.strToId(mpk, ID)
     hashID2 = mpk['h_l'][0] * dotprod2(range(1,mpk['n']), lam_func, mpk['h_l'], hID)        
     d = {}
     
     d[0] = mpk['h'] ** ((r1 * msk['t1'] * msk['t2']) + (r2 * msk['t3'] * msk['t4']))
     d[1] = (mpk['h'] ** (-msk['alpha'] * msk['t2'])) * (hashID2 ** (-r1 * msk['t2']))
     d[2] = (mpk['h'] ** (-msk['alpha'] * msk['t1'])) * (hashID2 ** (-r1 * msk['t1']))
     d[3] = hashID2 ** (-r2 * msk['t4'])
     d[4] = hashID2 ** (-r2 * msk['t3'])
     return { 'd':d }
Exemplo n.º 3
0
def transform(pk, skBlinded, ct):
    input = [pk, skBlinded, ct]
    policy_str, Ctl, C, Cr, Cpr, T1 = ct
    S, D, Dj, Djp = skBlinded
    policy = createPolicy(policy_str)
    attrs = prune(policy, S)
    coeff = getCoefficients(policy)
    Y = len(attrs)
    lam_func1 = lambda a, b, c, d, e, f: (pair((b[a] ** -c[a]), d[a]) * pair((e[a] ** c[a]), f[a]))
    A = dotprod2(range(0, Y), lam_func1, attrs, Cr, coeff, Dj, Djp, Cpr)
    result0 = pair(C, D) * A
    T0 = Ctl
    T2 = result0
    partCT = [T0, T1, T2]
    output = partCT
    return output
def transform(pk, sk, ct):
	input = [pk, sk, ct]
	policy_str, Ctl, C, Cr, Cpr, T1 = ct
	S, D, Dj, Djp = sk
	policy = createPolicy(policy_str)
	attrs = prune(policy, S)
	coeff = getCoefficients(policy)
	Y = len(attrs)
	lam_func1 = lambda a,b,c,d,e,f: (pair((b[a] ** -c[a]), d[a]) * pair((e[a] ** c[a]), f[a]))
	A = dotprod2(range(0, Y), lam_func1, attrs, Cr, coeff, Dj, Djp, Cpr)
	result0 = (pair(C, D) * A)
	T0 = Ctl
	T2 = result0
	partCT = [T0, T1, T2]
	output = partCT
	return output
def transform(ct):
	input = [pk, skBlinded, ct]
	policy_str, Ctl, C, Cr, Cpr, T1 = ct
	S, D, Dj, Djp = skBlinded
	policy = createPolicy(policy_str)
	attrs = prune(policy, S)
	coeff = getCoefficients(policy)
	Y = len(attrs)
	A = dotprod2(range(0,Y), transformLambdaFunc, attrs, Cr, coeff, Dj, Djp, Cpr)
	print(" A := ", A)
	result0 = (pair(C, D) * A)
	T0 = Ctl
	T2 = result0
	print("T2 :=>", result0)
	partCT = {'T0':T0, 'T1':T1, 'T2':T2}
	output = partCT
	return output
Exemplo n.º 6
0
def transform(ct):
    input = [pk, skBlinded, ct]
    policy_str, Ctl, C, Cr, Cpr, T1 = ct
    S, D, Dj, Djp = skBlinded
    policy = createPolicy(policy_str)
    attrs = prune(policy, S)
    coeff = getCoefficients(policy)
    Y = len(attrs)
    A = dotprod2(range(0, Y), transformLambdaFunc, attrs, Cr, coeff, Dj, Djp,
                 Cpr)
    print(" A := ", A)
    result0 = (pair(C, D) * A)
    T0 = Ctl
    T2 = result0
    print("T2 :=>", result0)
    partCT = {'T0': T0, 'T1': T1, 'T2': T2}
    output = partCT
    return output