Elliptic curve groups over finite fields

Let $p>3$ be a prime. An elliptic curve over $\mathbb{Z}/p\mathbb{Z}$ can be given by an equation of the form $$ E: y^2 = x^3 + ax + b $$ provided that $4a^3+27b^2$ is invertible in $\mathbb{Z}/p\mathbb{Z}$. We consider the set $$G=E(\mathbb{Z}/p\mathbb{Z})=\{(x,y)\in (\mathbb{Z}/p\mathbb{Z})^2 : y^2=x^3+ax+b\}\cup\{O\}$$ Geometry gives us a way to put a group law on $G$ that makes $G$ into a commutative group with identity element $O$. See for instance Wikipedia for a quick description of how the group operation works. Note that if $P=(x,y)$ is a point on $E$, then so is $(x,-y)$. For the group law, it is the negative of $P$. The group structure of $G$ varies a lot with choice of $a,b$, but the group orders stay within a fairly small range. Hasse proved in 1933 that $$p+1-2\sqrt{p}\leq \#G\leq p+1+2\sqrt{p}$$ By taking the multiples of a single point one can quickly get some cyclic subgroups inside $G$. That usually quickly restricts the possible group order for $\#G$ to very few possibilities (often just one). By considering the multiples of some other points one can then determine the actual group structure. The code below allows you to input $p,a,b$ to define an elliptic curve $E$, together with the $x$-coordinate of a point $P$ on $E$ (beware that not all possible values occur as $x$-coordinates!). It will then display the multiples of $P$.

Written by Nils Bruin