findcurve 700 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env sage
  2. import sys
  3. from sage.all import *
  4. # The prime order of libsnark's BN128 curve
  5. r = 21888242871839275222246405745257275088548364400416034343698204186575808495617
  6. F = GF(r)
  7. count = 0
  8. primecount = 0
  9. done = False
  10. while not done:
  11. b = F.random_element()
  12. try:
  13. E = EllipticCurve(F, [-3, b])
  14. Ec = E.cardinality()
  15. count += 1
  16. print "b =", b, "Ec =", Ec, "c =", count, "pc =", primecount
  17. Etc = 2 * r + 2 - Ec
  18. if Ec in Primes():
  19. primecount += 1
  20. print "Ec is prime; primecount =", primecount
  21. if Etc in Primes():
  22. print "Solution found:", b
  23. done = True
  24. except KeyboardInterrupt:
  25. print "Terminating on keyboard interrupt"
  26. sys.exit(1)
  27. except:
  28. pass