def encrypt(self, inp): print(self.__public.k) print(self.__public.m) return [ successive_square(i, self.__public.k, self.__public.m) for i in inp ]
def probably_prime(n): if n == 1 or n == 2: return False if n == 3: return True for a in ten_rands(2, int(math.sqrt(n - 1))): if successive_square(a, n - 1, n) != 1: return False return True
def solve(k, b, m, factors=None): #print("solve(k=%d,b=%d,m=%d" % (k, b, m)) #if gcd(b, m) != 1: # raise BaseException("B and m not relatively prime") phi = euler_phi(m, factors) if gcd(phi, k) != 1: raise BaseException("phi and k not relatively prime") for g, u, v in gxy_ascending(k, phi): if u >= 0: return successive_square(b, u, m)
def calculate_shared(self, y_other): return successive_square(y_other, self.e, self.p)
def calculate_yi(self): return successive_square(self.x, self.e, self.p)
def expotentiate(text, p, e): return [successive_square(c, e, p) for c in __codec.encode(KeyPair(PublicKey(m=p, k=e), None), text)]
def unsign(nums, e_from, n_from, e_to, n_to): dec = [successive_square(solve(e_to, i, n_to), e_from, n_from) for i in nums] return __codec.decode(None, dec)
def sign(text, e_from, n_from, e_to, n_to): pair_encode = KeyPair(PublicKey(m=min(n_from, n_to), k=-1), None) nums = __codec.encode(pair_encode, text) return [successive_square(solve(e_from, i, n_from), e_to, n_to) for i in nums]
def enrsa(text, e, n): return [successive_square(c, e, n) for c in __codec.encode(KeyPair(PublicKey(m=n, k=e), None), text)] pass
def encrypt(self, inp): print(self.__public.k) print(self.__public.m) return [successive_square(i, self.__public.k, self.__public.m) for i in inp]
def unsign(nums, e_from, n_from, e_to, n_to): dec = [ successive_square(solve(e_to, i, n_to), e_from, n_from) for i in nums ] return __codec.decode(None, dec)
def sign(text, e_from, n_from, e_to, n_to): pair_encode = KeyPair(PublicKey(m=min(n_from, n_to), k=-1), None) nums = __codec.encode(pair_encode, text) return [ successive_square(solve(e_from, i, n_from), e_to, n_to) for i in nums ]
def enrsa(text, e, n): return [ successive_square(c, e, n) for c in __codec.encode(KeyPair(PublicKey(m=n, k=e), None), text) ] pass