Advertisement
Second_Fry

crypto - 200 - Quite an EC task - fail

Mar 4th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. from z3 import *
  2.  
  3.  
  4. s = Solver()
  5.  
  6. M = Int('M')
  7. M = 93556643250795678718734474880013829509320385402690660619699653921022012489089
  8.  
  9. A = Int('A')
  10. A = 66001598144012865876674115570268990806314506711104521036747533612798434904785
  11.  
  12. B = Int('B')
  13.  
  14. Px = Int('Px')
  15. Px = 56027910981442853390816693056740903416379421186644480759538594137486160388926
  16.  
  17. Pxr = Int('Pxr')
  18. Pxrm = (Px ** 3 + A * Px) % M
  19.  
  20. Py = Int('Py')
  21. Py = 65533262933617146434438829354623658858649726233622196512439589744498050226926
  22.  
  23. Pym = Int('Pym')
  24. Pym = (Py ** 2) % M
  25.  
  26. Qx = Int('Qx')
  27. Qx = 61124499720410964164289905006830679547191538609778446060514645905829507254103
  28.  
  29. Qxr = Int('Qxr')
  30. Qxrm = (Qx ** 3 + A * Qx) % M
  31.  
  32. Qy = Int('Qy')
  33. Qy = 2595146854028317060979753545310334521407008629091560515441729386088057610440
  34.  
  35. Qym = Int('Qym')
  36. Qym = (Qy ** 2) % M
  37.  
  38. print 'Pym:  ', Pym
  39. print 'Pxrm: ', Pxrm
  40. print 'Qym:  ', Qym
  41. print 'Qxrm: ', Qxrm
  42.  
  43. s.add(Pym == (Pxrm + B) % M)
  44. s.add(Qym == (Qxrm + B) % M)
  45.  
  46. print s.check()
  47. print s.model()
  48.  
  49. # Much simpler solution without z3
  50. B = (Py ** 2 - Px ** 3 - Px * A) % M
  51. print B # B = 25255205054024371783896605039267101837972419055969636393425590261926131199030
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement