fork(44) download
  1.  
  2. def GCD(a, b):
  3. prevx, x = 1, 0
  4. prevy, y = 0, 1
  5. while b:
  6. q = a/b
  7. x, prevx = prevx - q*x, x
  8. y, prevy = prevy - q*y, y
  9. a, b = b, a%b
  10. return a, prevx, prevy
  11.  
  12.  
  13. def modinv(x, m):
  14. (gcd, c, d)= GCD(x,m)
  15. if c<0:
  16. c += m
  17. return c
  18.  
  19. q = 2**256 - 432420386565659656852420866394968145599
  20.  
  21. r = 0x6a93787fbfef76b95d2f4d7632b841459d440afaaa0873608436efcd3fbe3e54
  22. s1 = 0xe939c2360b5dcdb64c2bc8d5ffad06a7cdfde79f29ec967a5d5d07cdec142815
  23. s2 = 0x0df72a51154081325f81c87eb220387833aac888dcc4800b78d8423f59b1a711
  24. m1 = 0x1a374484e71c12135cda76c1261801e9f8fc27108e3f5e439679ef13eb300eae
  25. m2 = 0xe366e7bc7d5c12808b88e1b89c27436ac9cb3ae482dd044faeb7fab4654cbeac
  26.  
  27. print "%x" % (m1-m2) # -c92fa3379640006d2eae6af7760f4180d0cf13d3f49da60c183e0ba07a1caffe
  28. print "%x" % (s1-s2) # db4297e4f61d4c83ecaa00574d8cce2f9a531f164d28166ee484c58e92628104
  29.  
  30. mi = modinv(s1-s2, q)
  31. print "%x" % mi # 7369938cee97daa2c7e2b9aab4c07d7ba1189e177499caf6a2de68a71427428f
  32.  
  33. k = ((m1-m2)*mi) % q
  34. print "k = %x" % k # 6e3469cb1dec3ce994dfc5c88bb53971fe513749727bdfa4a44a38f294008136
  35.  
  36. rinv = modinv(r, q)
  37. xx = (s1*k-m1) % q
  38. print "xx=%x" % xx # 8321bc4f5e0a2973e5bdc9ba8194cc62c5be375216832cb5c04c28cab035dd42
  39. x = (xx * rinv) % q
  40. print "x=%x" % x # 1930a0cb6fe514b9ab03c652a61ac53b2c7ee6db417543de782503e690fab966
  41.  
Success #stdin #stdout 0.03s 44680KB
stdin
Standard input is empty
stdout
-c92fa3379640006d2eae6af7760f4180d0cf13d3f49da60c183e0ba07a1caffe
db4297e4f61d4c83ecaa00574d8cce2f9a531f164d28166ee484c58e92628104
7369938cee97daa2c7e2b9aab4c07d7ba1189e177499caf6a2de68a71427428f
k = 6e3469cb1dec3ce994dfc5c88bb53971fe513749727bdfa4a44a38f294008136
xx=8321bc4f5e0a2973e5bdc9ba8194cc62c5be375216832cb5c04c28cab035dd42
x=1930a0cb6fe514b9ab03c652a61ac53b2c7ee6db417543de782503e690fab966