Advertisement
Guest User

get_params

a guest
Apr 21st, 2018
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. modulus = 71521286555472299312252291246589709247849481750774732993492805730954699131789
  2. pubExp = 65537
  3. p = 261857794043121448213410325750790838383
  4. q = 273130256889334854338089243490350662083
  5. phi = (p - 1)*(q - 1)
  6.  
  7. def egcd(a, b):
  8.     if a == 0:
  9.         return (b, 0, 1)
  10.     else:
  11.         g, y, x = egcd(b % a, a)
  12.         return (g, x - (b // a) * y, y)
  13.  
  14. def modinv(a, m):
  15.     gcd, x, y = egcd(a, m)
  16.     if gcd != 1:
  17.         return None
  18.     else:
  19.         return x % m
  20.  
  21. def main():
  22.     privExp = modinv(pubExp, phi)
  23.     e1 = modinv(pubExp, (p-1))
  24.     e2 = modinv(pubExp, (q-1))
  25.     coeff = modinv(q, p)
  26.  
  27.     print("modulus = {0}\npubExp = {1}\nprivExp = {2}\np = {3}\nq = {4}\ne1 = {5}\ne2 = {6}\ncoeff = {7}".format(modulus, pubExp, privExp, p, q, e1, e2, coeff))
  28.  
  29. if __name__ == '__main__':
  30.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement