Exemple #1
0
 def prove(self, sk, x):
     pi = [i for i in range(sk['n'])]
     for i in range(sk['n']):
         result = dotprod(1, -1, i+1, lam_func, sk['u'], x) 
         pi[i] = sk['g1'] ** (sk['u_t'] * result)
     
     result0 = dotprod(1, -1, sk['n'], lam_func, sk['u'], x)
     pi_0 = sk['g1'] ** (sk['u_t'] * sk['u'][0] * result0)
     y = self.F(sk, x)
     return { 'y':y, 'pi':pi, 'pi0':pi_0 }
Exemple #2
0
 def prove(self, sk, x):
     pi = {} # [i for i in range(sk['n'])]
     for i in range(0, sk['n']):
         x = [group.init(ZR, long(j)) for j in x]
         dotProd0 = dotprod(1, -1, i+1, lam_func, sk['u'], x) 
         pi[i+1] = sk['g1'] ** (sk['u_t'] * dotProd0)
     
     dotProd1 = dotprod(1, -1, sk['n'], lam_func, sk['u'], x)
     pi[0] = sk['g1'] ** (sk['u_t'] * sk['u'][0] * dotProd1)
     y = self.F(sk, x)
     return { 'y':y, 'pi':pi } #, 'pi0':pi_0 }
Exemple #3
0
 def verify(self, mpk, ID, M, sig):
     if debug:
         print("Verify...")
     k = waters.hash(ID)
     m = waters.hash(M)
     (S1, S2, S3) = sig["S1"], sig["S2"], sig["S3"]
     A, g2 = mpk["A"], mpk["g2"]
     comp1 = dotprod(1, -1, mpk["z"], lam_func, mpk["ub"], k)
     comp2 = dotprod(1, -1, mpk["z"], lam_func, mpk["ub"], m)
     lhs = pair(S1, g2) * pair(S2, mpk["u1b"] * comp1) * pair(S3, mpk["u2b"] * comp2)
     # if ((pair(S1, g2) * pair(S2, mpk['u1b'] * comp1) * pair(S3, mpk['u2b'] * comp2)) == A):
     if lhs == A:
         return True
     return False
Exemple #4
0
 def keygen(self, mpk, msk, ID):
     if debug:
         print("Keygen alg...")
     k = waters.hash(ID)  # return list from k1,...,kz
     if debug:
         print("k =>", k)
     r = group.random(ZR)
     k1 = msk * ((mpk["u1t"] * dotprod(1, -1, mpk["z"], lam_func, mpk["u"], k)) ** r)
     k2 = mpk["g1"] ** -r
     return (k1, k2)
Exemple #5
0
 def sign(self, mpk, sk, M):
     if debug:
         print("Sign alg...")
     m = waters.hash(M)  # return list from m1,...,mz
     if debug:
         print("m =>", m)
     (k1, k2) = sk
     s = group.random(ZR)
     S1 = k1 * ((mpk["u2t"] * dotprod(1, -1, mpk["z"], lam_func, mpk["u"], m)) ** s)
     S2 = k2
     S3 = mpk["g1"] ** -s
     return {"S1": S1, "S2": S2, "S3": S3}
Exemple #6
0
    def verify(self, mpk, L, M, sig):
        u, S = sig['u'], sig['S']
        Lt = self.concat(L) 
        num_signers = len(L)
        h = [group.init(ZR, 1) for i in range(num_signers)]
        for i in range(num_signers):
            h[i] = H2(M, Lt, u[i])

        pk = [ H1(i) for i in L] # get all signers pub keys
        result = dotprod(1, -1, num_signers, lam_func, u, pk, h) 
        if pair(result, mpk['Pub']) == pair(S, mpk['g']):
            return True
        return False
    def verify(self, mpk, L, M, sig):
        u, S = sig["u"], sig["S"]
        Lt = self.concat(L)
        l = len(L)
        h = [group.init(ZR, 1) for i in range(l)]
        for i in range(l):
            h[i] = H2(M, Lt, u[i])

        pk = [H1(i) for i in L]  # get all signers pub keys
        result = dotprod(group.init(G1), -1, l, lam_func, u, pk, h)
        if pair(result, mpk["Pub"]) == pair(S, mpk["g"]):
            return True
        return False
Exemple #8
0
    def sign(self, sk, L, M):
        (IDs, IDpk, IDsk) = sk
        assert IDs in L, "signer should be an element in L"
        Lt = self.concat(L) 
        num_signers = len(L)
 
        u = [1 for i in range(num_signers)]
        h = [group.init(ZR, 1) for i in range(num_signers)]
        for i in range(num_signers):
            if IDs != L[i]:
               u[i] = group.random(G1)
               h[i] = H2(M, Lt, u[i])
            else:
               s = i
        
        r = group.random(ZR)
        pk = [ H1(i) for i in L] # get all signers pub keys
        u[s] = (IDpk ** r) * (dotprod(1, s, num_signers, lam_func, u, pk, h) ** long(-1))
        h[s] = H2(M, Lt, u[s])
        S = IDsk ** (h[s] + r)
        sig = { 'u':u, 'S':S }
        return sig
    def sign(self, sk, L, M):
        (IDs, IDpk, IDsk) = sk
        assert IDs in L, "signer should be an element in L"
        Lt = self.concat(L)
        l = len(L)

        u = [group.init(G1) for i in range(l)]
        h = [group.init(ZR, 1) for i in range(l)]
        for i in range(l):
            if IDs != L[i]:
                u[i] = group.random(G1)
                h[i] = H2(M, Lt, u[i])
            else:
                s = i

        r = group.random(ZR)
        pk = [group.hash(i, G1) for i in L]  # get all signers pub keys
        u[s] = (IDpk ** r) * ~dotprod(group.init(G1), s, l, lam_func, u, pk, h)
        h[s] = group.hash((M, Lt, u[s]), ZR)
        S = IDsk ** (h[s] + r)
        sig = {"u": u, "S": S}
        return sig
Exemple #10
0
 def F(self, sk, x):
     result = dotprod(1, -1, sk['n'], lam_func, sk['u'], x) 
     return pair(sk['g1'] ** (sk['u_t'] * sk['u'][0] * result), sk['h'])