I have an Elliptic Curve represented by the following equation and values:
Elliptic Curve: y^2 = x^3 + A*x + B mod M
M = 93556643250795678718734474880013829509320385402690660619699653921022012489089
A = 66001598144012865876674115570268990806314506711104521036747533612798434904785
B = 25255205054024371783896605039267101837972419055969636393425590261926131199030
What is the order of this Elliptic curve?
I thought it should be the same as the modulo, M?
In sage math, if I check the following, I get a different result:
F = FiniteField(M)
E = EllipticCurve(F, [A, B])
E.order() = 93556643250795678718734474880013829509196181230338248789325711173791286325820
However, the value of M is: 93556643250795678718734474880013829509320385402690660619699653921022012489089
These values look similar but they are not the same.
So, I want to know the following:
How is the order of the Elliptic Curve calculated? How is it related to modulus? Since there is a similarity between the two values?
Thanks.
Here is a late answer to this rather sage-related triple question:
Let us re-type the code, so that it comes with printed messages:
The above delivers:
So definitively,
ord, the order of the curve, and the primeM, the characteristic of the field of definition for the curve $E$, differ.To have an answer to (2) and (3) in the same time, let us go to:
Hasse's Theorem on Elliptic Curves (wiki page)
The notation $M$ is rather unusual for the prime, which is the characteristic of the base field for the curve. Usually, the notation is $p$ for such a prime, and in case the base field is finite, one denotes by $q$ the number of elements in this field, it is a power of $p$. So in our case, we would expect the relation for the order $\# E(F)$ of the finite group $(E(F),+)$ of points of $E$, ( elliptic curve with affine equation $y^2 = x^3 + Ax + B$, $A,B\in F$), defined over the field $F=\Bbb F_p$ with $p=M$ elements: $$ (p+1)-2\sqrt p\le \# E(F)\le (p+1)+2\sqrt p\ . $$ And indeed:
To see what happens in a "simple case", let us consider some small prime instead of $p$, for instance $p=11$ (in base ten). We build the list of all elliptic curves of the shape $y^2 = x^3+ax+b$, $a,b\in \Bbb F_{11}$, compute the order, and make a dictionary for which curves appear for which order. We expect cardinalities that differ from $(p+1)=12$ with "tolerance" $\pm 2\sqrt p=\pm2\sqrt{11}\approx 6.633\dots$.
Sage code (given, since it takes less space that the results):
And the
possible_ordersare:and all of them are between the bounds $12\pm6$. Note that any value occurs! To have a quick statistics how the $110$ curves fit in this list of orders...
And we get:
For short, the values of characteristic $p$ (in the OP $M$) of the base field $F=\Bbb F_p$ of the elliptic curve $E$, and the order of the group of its $F$-rational points $E(F)$, do not coincide, all we know in this generality is the double inequality (Hasse).
I can't to the same for $M$, but there are $M^2$ equations (and $M^2$ is huge) of the shape $y^2=x^3 +ax+b$ that can be written in characteristic $M$, some of them are leading to singular curves, (well, $\# F_M^\times =(M-1)$ is not a multiple of $3$, so $a\to a^3$ is injective, so for each $b$ there exists exactly one $a$ leading to a zero discriminant, so there are exactly $M$ singular curves...) but "a lot of them" are non-singular, thus elliptic, and they will fit somehow into the "small range" of possible orders between the two bounds $(M+1)\pm 2\sqrt M$. The curve from the OP is one of them...
First question, (1) How does sage compute the order?
Well, we have to look into the code. This can be done for instance by having an instance of the class defining the method
order, and asking for...we get a lot of information...
and so on, many, many doc string lines. We get then same information for the delegated work, this is the method
E.cardinality, and we can immediately put the hands on the relevant piece of code:So the computation is...
if we have already computed the ordered (in the same sage session), then it is cached, i.e. stored in the attribute
_order. If this attribute is set, we deliver it. Not the case in the OP.then we check if the
subfieldalgorithm should be used, this makes sense for "bigger fields" $\Bbb F_q$ with prime field $\Bbb F_p$ (so $q$ is a power of the characteristic $p$), and can be applied iff the $j$-invariant lives in a (strict) subfield of $\Bbb F_q$. Not the case in the OP. (We already work over the prime field.) So the code decides to use thealgoritm = "pari".and this delegates the work to the computation of the order
N = self.cardinality_pari(). So the true work goes to this method, and the only line of code in it isSo sage uses the
pari/gpassociated object, from it the method ellcard. It is as if we would require instead:Note: Using the "other algorithms" (implemented in
E.order) we get the same value. Code for them can be also inspected, this is the advantage of open source.