Level 2 · Learner · chapter 29

29 Discrete logs on toy curves

Level 2 · Learner. You will learn what the discrete logarithm problem is, how the visualizer solves it on small curves, and why the same method cannot touch Bitcoin’s curve. Read first: 28 Orders and subgroups.

The problem

Given G and a point Q, find the number k with k·G = Q. This is the discrete logarithm of Q. Going forward, from k to kG, is fast (doubling and adding, 27). Going back is the hard direction, and the security of Bitcoin’s signatures rests on it: a public key is kG, and k is the private key.

On curves with p up to 2²² the visualizer solves it for every point you type whose order divides ord(G), and writes the answer as the card’s k. It uses baby-step giant-step:

  1. compute the “baby steps” 0·G, 1·G, …, (m − 1)·G, with m about √ord(G), and remember them;
  2. from Q, take “giant steps” backwards, subtracting m·G each time, until you land on a baby step: if Q − i·mG = jG, then k = i·m + j.

That needs about 2√ord(G) additions instead of ord(G).

Example 29.1 · Every k on F₁₇

F₁₇: P₁ = (16, 4) is 13G, P₂ = (6, 3) is 2G, and their sum (3, 16) is 15G; three pinned cards

Open this view: (16, 4) + (6, 3) on F₁₇

Do it yourself

  1. In Curve, pick the preset y² = x³ + 2x + 2 over F₁₇, Paar & Pelzl.
  2. Type (16, 4) in P₁.
  3. In Display, turn off Chord construction (K).
  4. In the 3D view, click P₁, P₂ and the result to pin their cards.
  5. Read the Relations section in the panel.

Look at: three cards with k: (16, 4) = 13G, (6, 3) = 2G, and their sum (3, 16) = 15G.

Why: 13 + 2 = 15, so the sum of the points is the point of the summed k: adding points adds their k. That rule is why the visualizer can carry k through operations, and why kG is a group homomorphism, in the language of Level 4.

Example 29.2 · Discrete logs on F₁₀₀₀₉

On y² = x³ + 7 over F₁₀₀₀₉, G = (1, 1171) has order 2548, so the cofactor is 10192 / 2548 = 4. Type a point as plain (x, y): the visualizer does not know where it came from, and finds k itself.

F₁₀₀₀₉ with P₁ = (3897, 1487): the card says k = 1000

Open this view: (3897, 1487) on F₁₀₀₀₉

P₁ typed as (x, y) k found by the visualizer open
(2298, 3395) 100 open
(3897, 1487) 1000 open
(747, 219) 2000 open
(1, 8838) 2547 open

Do it yourself

  1. In Curve, pick the preset y² = x³ + 7 over F₁₀₀₀₉, dense and 6-fold symmetric.
  2. Type (3897, 1487) in P₁.
  3. Empty P₂.
  4. In Display, turn off Chord construction (K).
  5. In the 3D view, click P₁ to pin its card.
  6. Read the Inspector section in the panel.

Look at: (3897, 1487) gets k = 1000. The table gives three more points and the k the visualizer found for each; the points were made by the tutorials’ scripts as 100G, 2000G and 2547G, and the visualizer recovers exactly those numbers.

Why: with ord(G) = 2548, baby-step giant-step stores 51 baby steps (51 is ⌈√2548⌉) and takes at most about as many giant steps. 2547G is −G, the mirror image of G = (1, 1171): look at its x.

Example 29.3 · No k: a point outside ⟨G⟩

F₁₀₀₀₉ with P₁ = (2, 3841): order 2548 like G, but no k

Open this view: (2, 3841) on F₁₀₀₀₉

Do it yourself

  1. In Curve, pick the preset y² = x³ + 7 over F₁₀₀₀₉, dense and 6-fold symmetric.
  2. Type (2, 3841) in P₁.
  3. Empty P₂.
  4. In Display, turn off Chord construction (K).
  5. In the 3D view, click P₁ to pin its card.
  6. Read the Inspector section in the panel.

Look at: (2, 3841) has order 2548, the same as G, but its card has no k.

Why: with cofactor 4, only one point in four is a multiple of G. The search runs to its end without landing on a baby step, and that proves Q is not in ⟨G⟩: there is no k to find.

Why Bitcoin’s curve is safe from this

On secp256k1, G has order n, a 256-bit number. Baby-step giant-step would need about √n steps, about 3.403 × 10³⁸, and storage for as many points. No computer, and no number of computers, comes anywhere near that; no better general method is known either (Pollard’s rho needs about the same √n time with little memory). That is the gap between the two directions: kG takes a few hundred curve operations, k from kG takes about 10³⁸.

The visualizer never attempts a discrete log on secp256k1 or P-256. It shows k only where it was given, typed as kG, and carries it through operations (Example 26.2).

Try it yourself

Recap

Next, Level 3 begins: 31 secp256k1 in the panel. Or continue with Level 4 at 41 The mapping.