fork 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 = 0x00cb2088d5195ca39a3dca76af7656f88c5e49b993c9161f3745fba2d4dc553913
  22. s1 = 0x047a9f8402c81fb316cce65bb1713d5573fa3a1076d1e00f4c7fd466a2fff710
  23. s2 = 0x0ecbd01b4ed435532c3a2dd57c870418adc3375d00ef95300338cba6692bb044
  24. m1 = 0x8fe9e86b959cea938da0070d219ea74ecf8c94595b81d290d0eafda8db4c544d
  25. m2 = 0x4c02939c161b1ad60941d07b81ae922acc1182a80dfa7dea33c2a27e1645d37f
  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 63684KB
stdin
Standard input is empty
stdout
43e754cf7f81cfbd845e36919ff01524037b11b14d8754a69d285b2ac50680ce
-a5130974c0c15a0156d4779cb15c6c339c8fd4c8a1db520b6b8f73fc62bb934
d7330052d09c3b1ab071c9137cdedc69330d862274d671ff2616cc879d638b3d
k = 542a69d4a9ce03a10e92de0936a97314a7b6b12323b11c3fe1ae043c05b3aa7d
xx=9fb3dbd17b82a249d989e9d4a854e3c24869165b5ad6874d9bfb3c723b9e173c
x=f0a3f0f89e5561330002e06441224bc28dc63295a6bb25a469bb8e3f7aef99a