testcurve 747 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env sage
  2. import sys
  3. import os
  4. from sage.all import *
  5. def dump_point(P):
  6. xy = P.xy()
  7. xyh = map(lambda v:hex(int(v))[2:-1], xy)
  8. return xyh[0] + " " + xyh[1]
  9. # PTWIST-168 prime curve
  10. p = 2**168 - 2**8 - 1
  11. F = GF(p)
  12. b = 114301813541519167821195403070898020343878856329174
  13. x = 2
  14. y = 342581008510239659405023808572191026457361540109042
  15. r = 374144419156711147060143343079555958890598677719703
  16. E = EllipticCurve(F, [-3, b])
  17. print E
  18. P = E.random_point()
  19. Q = E.random_point()
  20. s = F.random_element()
  21. cmd = "./ptwist168 " + dump_point(P) + " " + dump_point(Q) + " " + hex(int(s))[2:-1]
  22. print cmd
  23. os.system(cmd)
  24. P2 = 2*P
  25. PQ = P+Q
  26. for i in xrange(1000):
  27. P = int(s)*P
  28. print dump_point(P2)
  29. print dump_point(PQ)
  30. print dump_point(P)