def encrypt(self, i_pk, o_pk, M : G1): r, s = group.random(ZR, 2) Y = o_pk['pk'] ** r W = o_pk['h'] ** r S = i_pk['g'] ** s F = e(S, Y) H = o_pk['h'] ** s G = e(S, W) * e(M, H) return { 'F':F, 'G':G, 'H':H }
def encrypt(self, i_pk, o_pk, M: G1): r, s = group.random(ZR, 2) Y = o_pk['pk']**r W = o_pk['h']**r S = i_pk['g']**s F = e(S, Y) H = o_pk['h']**s G = e(S, W) * e(M, H) return {'F': F, 'G': G, 'H': H}
def decrypt(self, a, ct, M : [G1]): F, G, H = ct['F'], ct['G'], ct['H'] Q = G * (F ** -(1 / a)) for m in M: if e(m, H) == Q: return m return False
def decrypt(self, a, ct, M: [G1]): F, G, H = ct['F'], ct['G'], ct['H'] Q = G * (F**-(1 / a)) for m in M: if e(m, H) == Q: return m return False