Пример #1
0
    def prover_state1(self):
        print("PROVER 1: ")
        (g, V) = Sigma.get(self, ['g', 'V'])
        r = self.group.random(G2)
        a1 = pair(g, r)
        a2 = pair(V, r)
        print("send r =>", r)
        print("send a1 =>", a1)
        print("send a2 =>", a2)
        pk = Sigma.get(self, ['g', 'V', 'H'], dict)

        Sigma.store(self, ('r', r))
        Sigma.setState(self, 3)
        return {'a1': a1, 'a2': a2, 'pk': pk}
Пример #2
0
    def prover_state1(self):
        print("PROVER 1: ")
        (g, V) = Sigma.get(self, ['g', 'V'])
        r = self.group.random(G2)
        a1 = pair(g, r)
        a2 = pair(V, r)
        print("send r =>", r)
        print("send a1 =>", a1)
        print("send a2 =>", a2)
        pk = Sigma.get(self, ['g','V','H'], dict)

        Sigma.store(self, ('r',r) )
        Sigma.setState(self, 3)
        return { 'a1':a1, 'a2':a2, 'pk':pk }
Пример #3
0
    def prover_state1(self):
        print("PROVER 1: ")
        (g, V) = Sigma.get(self, ['g', 'V'])
        r1, r2 = self.group.random(ZR, 2)

        a = (pair(V, g)**-r1) * (pair(g, g)**r2)
        print("send g =>", g)
        print("send V =>", V)
        print("send r1 =>", r1)
        print("send r2 =>", r2)
        print("send a =>", a)

        pk = Sigma.get(self, ['g', 'V', 'y'], dict)
        Sigma.store(self, ('r1', r1), ('r2', r2))
        Sigma.setState(self, 3)
        return {'a': a, 'pk': pk}
Пример #4
0
    def prover_state1(self):
        print("PROVER 1: ")
        (g, V) = Sigma.get(self, ['g', 'V'])
        r1, r2 = self.group.random(ZR, 2)

        a = (pair(V, g) ** -r1) * (pair(g, g) ** r2)
        print("send g =>", g)
        print("send V =>", V)
        print("send r1 =>", r1)
        print("send r2 =>", r2)
        print("send a =>", a)

        pk = Sigma.get(self, ['g','V','y'], dict)
        Sigma.store(self, ('r1',r1), ('r2',r2) )
        Sigma.setState(self, 3)
        return { 'a':a, 'pk':pk }
Пример #5
0
 def prover_state3(self, input):
     print("PROVER 3: ")
     (r, h, c) = Sigma.get(self, ['r', 'h', 'c'])
     print("input c =>", c)
     z = r * (h ** -c)
     Sigma.setState(self, 5)
     # need store and get functions for db        
     return {'z':z }
Пример #6
0
 def prover_state3(self, input):
     print("PROVER 3: ")
     (r, h, c) = Sigma.get(self, ['r', 'h', 'c'])
     print("input c =>", c)
     z = r * (h**-c)
     Sigma.setState(self, 5)
     # need store and get functions for db
     return {'z': z}
Пример #7
0
 def verifier_state4(self, input):
     (g, H, a, c, z) = Sigma.get(self, ['g','H','a','c','z'])
     if a == (pair(g,z) * (H ** c)):
         print("SUCCESS!!!!!!!"); result = 'OK'
     else:
         print("Failed!!!"); result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #8
0
 def prover_state3(self, input):
     print("PROVER 3: ")
     (r1, r2, v, sigma, c) = Sigma.get(self, ['r1','r2','v','sigma', 'c'])
     print("input c =>", c)
     z1 = r1 - sigma * c # need a way to get sigma index as part of init index (1..N)
     z2 = r2 - v * c 
     print("send z1 =>", z1)
     print("send z2 =>", z2)
     Sigma.setState(self, 5)
     return {'z1':z1, 'z2':z2 }
Пример #9
0
 def prover_state3(self, input):
     print("PROVER 3: ")
     (r1, r2, v, sigma, c) = Sigma.get(self,
                                       ['r1', 'r2', 'v', 'sigma', 'c'])
     print("input c =>", c)
     z1 = r1 - sigma * c  # need a way to get sigma index as part of init index (1..N)
     z2 = r2 - v * c
     print("send z1 =>", z1)
     print("send z2 =>", z2)
     Sigma.setState(self, 5)
     return {'z1': z1, 'z2': z2}
Пример #10
0
 def verifier_state4(self, input):
     print("VERIFIER 4: ")
     (a1, a2, c, W, z, pk) = Sigma.get(self, ['a1','a2','c','W','z','pk'])
     g, V, H = pk['g'], pk['V'], pk['H']
     if a1 == pair(g,z) * (H ** c) and a2 == pair(V,z) * (W ** c):
         print("SUCCESS!!!!!!!"); result = 'OK'
     else:
         print("Failed!!!"); result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #11
0
 def verifier_state4(self, input):
     (g, H, a, c, z) = Sigma.get(self, ['g', 'H', 'a', 'c', 'z'])
     if a == (pair(g, z) * (H**c)):
         print("SUCCESS!!!!!!!")
         result = 'OK'
     else:
         print("Failed!!!")
         result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #12
0
 def verifier_state4(self, input):
     print("VERIFIER 4: ")
     (a, c, z1, z2, pk) = Sigma.get(self, ['a','c','z1','z2','pk'])
     g, y, V = pk['g'], pk['y'], pk['V']
     print("get a =>", a)
     if a == (pair(V,y) ** c) * (pair(V,g) ** -z1) * (pair(g,g) ** z2):
         print("SUCCESS!!!!!!!"); result = 'OK'
     else:
         print("Failed!!!"); result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #13
0
 def verifier_state4(self, input):
     print("VERIFIER 4: ")
     (a1, a2, c, W, z, pk) = Sigma.get(self,
                                       ['a1', 'a2', 'c', 'W', 'z', 'pk'])
     g, V, H = pk['g'], pk['V'], pk['H']
     if a1 == pair(g, z) * (H**c) and a2 == pair(V, z) * (W**c):
         print("SUCCESS!!!!!!!")
         result = 'OK'
     else:
         print("Failed!!!")
         result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #14
0
 def verifier_state4(self, input):
     print("VERIFIER 4: ")
     (a, c, z1, z2, pk) = Sigma.get(self, ['a', 'c', 'z1', 'z2', 'pk'])
     g, y, V = pk['g'], pk['y'], pk['V']
     print("get a =>", a)
     if a == (pair(V, y)**c) * (pair(V, g)**-z1) * (pair(g, g)**z2):
         print("SUCCESS!!!!!!!")
         result = 'OK'
     else:
         print("Failed!!!")
         result = 'FAIL'
     Sigma.setState(self, 6)
     Sigma.setErrorCode(self, result)
     return result
Пример #15
0
 def prover_state3(self, input):
     (r, h, c) = Sigma.get(self, ['r','h','c'])
     z = r * (h ** -c)
     Sigma.setState(self, 5)
     return {'z':z }
Пример #16
0
 def prover_state3(self, input):
     (r, h, c) = Sigma.get(self, ['r', 'h', 'c'])
     z = r * (h**-c)
     Sigma.setState(self, 5)
     return {'z': z}
Пример #17
0
 def prover_state1(self):
     (g, h, H) = Sigma.get(self, ['g', 'h', 'H'])
     r = self.group.random(G2)
     a = pair(g, r)
     Sigma.setState(self, 3)
     return { 'r':r, 'a':a, 'g':g, 'h':h, 'H':H }        
Пример #18
0
 def prover_state1(self):
     (g, h, H) = Sigma.get(self, ['g', 'h', 'H'])
     r = self.group.random(G2)
     a = pair(g, r)
     Sigma.setState(self, 3)
     return {'r': r, 'a': a, 'g': g, 'h': h, 'H': H}