Go to the first, previous, next, last section, table of contents.

### `ecm_add_ff`, `ecm_sub_ff`, `ecm_chsgn_ff`

ecm_add_ff(p1,p2,ec)
ecm_sub_ff(p1,p2,ec)
ecm_chsgn_ff(p1)
:: Addition, Subtraction and additive inverse for points on an elliptic curve.
return
vector or 0
p1,p2
vector of length 3 or 0
ec
vector of length 2
• Let p1, p2 be points on the elliptic curve represented by ec over the current base field. ecm_add_ff(p1,p2,ec), ecm_sub_ff(p1,p2,ec) and ecm_chsgn_ff(p1) returns p1+p2, p1-p2 and -p1 respectively.
• If the current base field is a prime field of odd order, then ec represents y^2=x^3+ecx+ec. If the characteristic of the current base field is 2, then ec represents y^2+xy=x^3+ecx^2+ec.
• The point at infinity is represented by 0.
• If an argument denoting a point is a vector of length 3, then it is the projective coordinate. In such a case the third coordinate must not be 0.
• If the result is a vector of length 3, then the third coordinate is not equal to 0 but not necessarily 1. To get the result by the affine coordinate, the first and the second coordinates should be divided by the third coordinate.
• The check whether the arguments are on the curve is omitted.
``` setmod_ff(1125899906842679)\$
 EC=newvect(2,[ptolmp(1),ptolmp(1)])\$
 Pt1=newvect(3,[1,-412127497938252,1])\$
 Pt2=newvect(3,[6,-252647084363045,1])\$
 Pt3=ecm_add_ff(Pt1,Pt2,EC);
[ 560137044461222 184453736165476 125 ]
 F=y^2-(x^3+EC*x+EC)\$
 subst(F,x,Pt3/Pt3,y,Pt3/Pt3);
0
 ecm_add_ff(Pt3,ecm_chsgn_ff(Pt3),EC);
0
 D=ecm_sub_ff(Pt3,Pt2,EC);
[ 886545905133065 119584559149586 886545905133065 ]
 D/D==Pt1/Pt1;
1
 D/D==Pt1/Pt1;
1
```
References
section `setmod_ff`

Go to the first, previous, next, last section, table of contents.