PARI/GP is a mathematics calculator and programmable library for elliptic-curve number theory. Its libpari API lets C programs reuse optimized routines for computing curve cardinalities, point orders, and factors. section 6.0 section 6.1
A practical workflow combines interactive checking with linked-library computation:
- Start gp, configure the PARI environment through .gprc, and use the prompt for exploratory calculations. section 6.1.1
- Construct a finite-field elliptic curve with ellinit([a4, a6], p), using a vector for the coefficients and a prime field. section 6.1.2
- Inspect E.group to obtain the curve cardinality, cyclic structure, and generators, including coordinates represented modulo p. section 6.1.2
- For C integration, initialize stack and prime-storage limits, represent PARI values with GEN, and debug failures by checking argument types. section 6.1.3
Counting points on a toy curve
The command E=ellinit([1,17],1187) creates y²=x³+x+17 over the field modulo 1187. E.group reports 1148 points and a generator (702,1007), with coordinates displayed as modular values. section 6.1.2
Listing 6.1 Finding curves: Initialize
int main()
{
GEN y, E, f, z, a1, a3, a2, ell5, num, tmp;
int k, pw2, pw[4];
unsigned long a4coef, a6coef;
PARI_sp av;
PARI_init(1024*1024*1024, 5*1024*512); #1
z = gp_read_str(",0xac000000000000000000000000000000000000001"); #2
y = ffgen(z, -1); #3
a1 = gen_0; #4
a3 = gen_0; #4
a2 = gen_0; #4
ell5 = zerovec( 5);
gel(ell5, 1) = a1; #5
gel(ell5, 2) = a2; #5
gel(ell5, 3) = a3; #5
a4coef = 1; #6
a6coef = 0x01; #6
num = muluu(3, 5); #7
num = mului(7, num); #7
num = mului(11, num); #7
The initialization listing shows the C-side execution flow: declare GEN values, call PARI_init, create the field, assemble elliptic-curve coefficients, and prepare small-prime data. section 6.2.1
