crypto
← Back to practices Practice 06

Elliptic Curve

Compute quadratic residues and their roots, enumerate the rational points of an elliptic curve, and save them to a file. Test curve generation, point addition, and doubling.

p is assumed prime; primality is not tested. The browser accepts p ≤ 10000 to keep output manageable. QRₚ contains nonzero squares; zero and its root are listed separately.

01 / QRₚ

Quadratic residues

Find each residue and all its roots modulo p.

02 / E(𝔽ₚ)

Rational points

y² ≡ x³ + ax + b (mod p). The count includes (0, 1, 0).

Elliptic curve arithmetic

Integers up to 2048 bits. Use decimals and points (x, y, 1); infinity is (0, 1, 0). Addition and doubling assume prime p and check that points belong to the curve.

Generate a curve

Miller–Rabin: 32 rounds, probable prime. Classroom randomness. The seed repeats a run in the same environment.

P + Q

P (x1, y1, z1)
Q (x2, y2, z2)

2P

P (x1, y1, z1)