For a finite field elliptic curve we can search for the first 20 points for a curve of \(y^2 = x^3 + ax +b\) and for a defined prime number (\(p\)) [Improved version] Note: this version will not find all the ECC points.
Simple Finding 20 Elliptic Curve Points |
Coding
The outline code is:
import math import sys p=37 startval=1 a=0 b=7 if (len(sys.argv)>1): p=int(sys.argv[1]) if (len(sys.argv)>2): a=int(sys.argv[2]) if (len(sys.argv)>3): b=int(sys.argv[3]) def findpoints(p,a,b): found=0 for x in range(1,2*p): val=((x*x*x) + a*x+ b) % p res = math.sqrt(val) if (found>19 or x>p): return if (abs(res-int(res))<0.0001): print("(",x,int(res),")",end=''), found=found+1 print ("A: ",a) print ("B: ",b) print ("Prime number:\t\t",p) if (a==0): print ("Elliptic curve is:\t\ty^2=x^3+",b) else: print ("Elliptic curve is:\t\ty^2=x^3+",a,"x+",b) print ("Finding the first 20 points") print findpoints(p,a,b)