Level 3 · Bitcoiner · chapter 31

31 secp256k1 in the panel

Level 3 · Bitcoiner. Bitcoin’s curve as the visualizer shows it: its parameters, what each row of Curve facts says, and why two remainders of p matter for key handling. Read first: 11 Start here and 15 Mirror images; Level 2 for the arithmetic.

The parameters

secp256k1 is y² = x³ + 7 over F_p (a = 0, b = 7) with

The trace t = p + 1 − n is 432420386565659656852420866390673177327, a 129-bit number well inside the Hasse bound |t| ≤ 2√p. The visualizer recognises the curve from (p, a, b), whichever way p is typed, and then uses the known n, h, β and λ instead of counting points.

Example 31.1 · The Curve facts of secp256k1

the Curve section of the opening view: secp256k1’s p, a and b, p mod 4 and 3, the named curve, Δ, j, n, h and β

Open this view: secp256k1’s Curve facts

Do it yourself

  1. In Curve, pick the preset secp256k1: G and −G (mirror pair).
  2. Read the Curve section in the panel.

Look at each row:

Why p mod 4 matters. Decompressing a 02/03 key needs a square root mod p. For p ≡ 3 (mod 4) it is one exponentiation: y = (x³ + 7)^((p+1)/4) mod p, then pick y or p − y by the prefix’s parity. For G: x³ + 7 ≡ 4866d6a5ab41ab2c6bcc57ccd3735da5f16f80a548e5e20a44e4e9b8118c26f2, and raising it to (p + 1)/4 = 3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c gives 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8, which is G’s y. Primes ≡ 1 (mod 4) need the slower Tonelli–Shanks loop; the visualizer has both.

Why p mod 3 matters. p ≡ 1 (mod 3) means F_p contains the cube roots of unity, so with a = 0 the map (x, y) ↦ (βx, y) is an automorphism of the curve. On the group it acts as multiplication by λ = 5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72 (mod n), with β = 7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee. That is the GLV endomorphism libsecp256k1 uses to speed up multiplication.

Example 31.2 · G in full, in the Inspector

G pinned on the torus, and the Inspector with its full x and y, parity and every SEC encoding

Open this view: G in the Inspector

Do it yourself

  1. In Curve, pick the preset secp256k1: G and −G (mirror pair).
  2. In the 3D view, click P₁ to pin its card.
  3. Read the Inspector section in the panel.

Look at: x and y as full 32-byte hex with copy buttons, “even, prefix 02 / 06”, k = 1, order “n (prime)”, and every SEC encoding. The cards shorten x and y to their first ten and last six hex digits; the Inspector never shortens.

Example 31.3 · p typed three ways

the Curve section with p typed as 2**256 - 0x1000003d1: still recognised as secp256k1

Open this view: p = 2**256 − 0x1000003d1

p typed as Curve facts open
2^256 - 2^32 - 977 named secp256k1 open
2**256 - 0x1000003d1 named secp256k1 open
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f named secp256k1 open

Do it yourself

  1. In Curve, pick the preset secp256k1: G and −G (mirror pair).
  2. Type 2**256 - 0x1000003d1 in Prime p.
  3. Read the Curve section in the panel.

Look at: the named row stays “secp256k1” for every spelling in the table. Fields accept integer expressions (+ - * / % ^ **, brackets, hex 0x, binary 0b, octal 0o, _ separators); ^ is a power, not XOR. The evaluated p is what the facts show and what the copy button copies.

Try it yourself

Recap

Next: 32 Private key → public key.