Example #1
0
 def check_mul(self, val: int, n: Integer):
     Q = self.curve.O.project()
     while val:
         if val & 1:
             Q = Q + self
             assert Q.z != 0 and n.gcd(Q.z)
         self = self + self
         val >>= 1
     return Q
Example #2
0
 def _sign(self, M, K):
     if (not hasattr(self, 'x')):
         raise TypeError('Private key not available in this object')
     p1=self.p-1
     K = Integer(K)
     if (K.gcd(p1)!=1):
         raise ValueError('Bad K value: GCD(K,p-1)!=1')
     a=pow(self.g, K, self.p)
     t=(Integer(M)-self.x*a) % p1
     while t<0: t=t+p1
     b=(t*K.inverse(p1)) % p1
     return [int(a), int(b)]
Example #3
0
 def _sign(self, M, K):
     if (not hasattr(self, 'x')):
         raise TypeError('Private key not available in this object')
     p1=self.p-1
     K = Integer(K)
     if (K.gcd(p1)!=1):
         raise ValueError('Bad K value: GCD(K,p-1)!=1')
     a=pow(self.g, K, self.p)
     t=(Integer(M)-self.x*a) % p1
     while t<0: t=t+p1
     b=(t*K.inverse(p1)) % p1
     return map(int, (a, b))