ellinit initializes a PARI/GP elliptic-curve structure from coefficients and a defining field. For an ordinary curve over a prime finite field, pass the vector [a4, a6] and the prime; the brackets are required because they construct a vector. section 6.1.2
The returned ell structure contains derived curve data, including the standard coefficients, discriminant, and j-invariant. Its internal layout is deliberately undefined, so use documented operations rather than indexing it directly. A null result means the inputs do not define a constructible curve. section 6.1.2
Use ellinit in two closely related forms:
- PARI/GP finite-field form: ellinit([a4, a6], p) initializes y² = x³ + a4x + a6 over the prime field defined by p. section 6.1.2
- libpari general form: provide a five-entry coefficient vector; for ordinary curves over large prime fields, only a4 and a6 need nonzero values. section 6.2.1
- Finite-field initialization also makes group information available: the point count, cyclic structure, generators, and their combined group representation. section 6.1.2
A small curve over 1187
E = ellinit([1, 17], 1187) constructs the curve y² = x³ + x + 17 modulo 1187. Its group information reports 1148 points, a cyclic group, and generator (702, 1007), represented with Mod values. section 6.1.2
In a cryptographic curve search, construct E inside the candidate loop, obtain its cardinality with ellcard, remove powers of two and small factors, and test the remaining factor for primality. C implementations must also reclaim temporary PARI stack values with gerepileall. section 6.2.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
Shows libpari setup: finite-field construction, zero-filled coefficient initialization, coefficient assignment, and candidate-search constants. section 6.2.1
