liveBook · Manning

Ellinit

As explained in Elliptic Curve Cryptography for Developers

ellinit is a PARI/GP function that initializes an elliptic-curve data structure from curve coefficients and a defining field or modulus.

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

How Elliptic Curve Cryptography for Developers covers it

How deep it goes
Explains argument conventions, derived group data, and C-loop integration, but defers the ell structure's internal layout.
Examples
Demonstrates [1,17] modulo 1187, group output, and libpari candidate initialization.
What it assumes
Assumes elliptic-curve coefficients and finite fields, while teaching vector syntax and zero-based general-curve setup.
What you can do after
Operate PARI/GP or libpari to initialize curves and inspect finite-field group information.
How it connects
Connects elliptic curves with finite fields, elliptic-curve groups, cardinality computation, and primality testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elliptic Curve Cryptography for Developers. The section links point to the parts of the book it draws on.