def compare(self, y, x, e, v, n):
     if BasicFunctions.fast_modulo_exponentiation(
             y, 2, n) == x % n * BasicFunctions.fast_modulo_exponentiation(
                 v, e, n) % n:
         return True
     else:
         return False
     pass
 def round_(self):
     x = self.usrA.calcX(self.tc.n)
     e = self.ursB.coinToss()
     y = self.usrA.calcY(e, self.tc.n)
     if self.compare(y, x, e, self.usrA.open, self.tc.n):
         print("Left = ",
               BasicFunctions.fast_modulo_exponentiation(y, 2, self.tc.n),
               "Right =",
               (x % self.tc.n) * BasicFunctions.fast_modulo_exponentiation(
                   self.usrA.open, e, self.tc.n) % self.tc.n)
         print("e = ", e)
         return True
     elif not self.compare(y, x, e, self.usrA.open, self.tc.n):
         print("Left = ",
               BasicFunctions.fast_modulo_exponentiation(y, 2, self.tc.n),
               "Right =",
               (x % self.tc.n) * BasicFunctions.fast_modulo_exponentiation(
                   self.usrA.open, e, self.tc.n) % self.tc.n)
         print("e = ", e)
         return False
     pass
Esempio n. 3
0
 def calcX(self, n):
     self.r = random.randint(1, n - 1)
     self.x = BasicFunctions.fast_modulo_exponentiation(self.r, 2, n)
     return self.x
Esempio n. 4
0
 def calcY(self, e, n):
     if self.secret is None or self.open is None:
         self.secret = 100500
         self.open = 100500
     self.y = (self.r % n) * BasicFunctions.fast_modulo_exponentiation(self.secret, e, n) % n
     return self.y
Esempio n. 5
0
 def initUserA(self, n):
     self.secret = BasicFunctions.gen_g(n)
     self.open = BasicFunctions.fast_modulo_exponentiation(self.secret, 2, n)
     return self