Part 1 ended with a key pair: a private row number d and a public point Q = dG. An output that says “spendable by Q” needs one more thing. The owner has to prove they know d for this transaction, and only this one, without revealing it. Handing over d would work exactly once.

A signature is that proof. It is two numbers, and checking it needs only Q. The mechanism is a trick with one extra secret that the signer invents and throws away. I build it on the 31-point curve first, because there you can check every step by hand.

The recipe

The Elliptic Curve Digital Signature Algorithm (ECDSA) signs a message hash z with a private key d. Points live mod p, as before; scalars live mod n, the number of points in the group.

Symbol Secret Meaning
d yes private key, 1 ≤ d < n
Q = dG no public key
z no hash of the message, reduced mod n
k yes, for one signature nonce: a fresh random scalar
R = kG no the nonce as a point
r = R.x mod n no first half of the signature
s = k⁻¹(z + r·d) mod n no second half

The signer computes R, takes its x-coordinate as r, and mixes k, z, r, and d into s. The pair (r, s) is the signature. Notice what s contains: d and k, bound together in one equation with two unknowns. Knowing s tells you nothing about either one alone.

One signature on 31 points

Take d = 7, so Q = 7G = (25, 25), from the table in Part 1. Sign a message whose hash is z = 15, using the nonce k = 10:

R = 10G = (42, 36)              r = 42 mod 31 = 11
s = 10⁻¹ · (15 + 11·7) mod 31 = 28 · 92 mod 31 = 3
signature (r, s) = (11, 3)

The x-coordinate 42 lives mod 43, and r lives mod 31, so they differ. On secp256k1 the group order n is so close to the field prime p that r differs from R.x in roughly one signature in 2¹²⁸. On the toy curve it happens all the time. Part 5 will need to remember it.

The verifier holds Q, z, r, and s. It never sees k or d:

w  = s⁻¹ mod n                  = 21
u1 = z·w mod n                  = 5
u2 = r·w mod n                  = 14
u1·G + u2·Q = 5G + 14Q = 5G + 98G = 103G = 10G = (42, 36)
(42 mod 31) = 11 = r            → valid

The point it computed has the same x-coordinate as R, which a forger without d has no known way to arrange. Change the message to z = 16 and the same signature fails: u1 becomes 26, and 26G + 14Q = 26G + 98G = 124G is the point at infinity, because 124 = 4 · 31. The signature is bound to the message it was made for.

Why verification works

Start from the definition of s and solve for k:

s = k⁻¹(z + r·d)
k = s⁻¹z + s⁻¹r·d
kG = (s⁻¹z)·G + (s⁻¹r)·(dG) = u1·G + u2·Q

The left side is R. The right side is built from public values only. That is the entire proof, and it uses a single property from Part 1: adding points adds their scalars. The verifier rebuilds R without ever learning the k that produced it.

The nonce is a second private key

The same equation shows what must never happen. Rewrite it as s·k = z + r·d: one equation, two secrets. It stays safe while k is used once. Sign two different messages with the same k and r repeats, which anyone can see on the chain, and the two signatures become two equations that are linear in the two unknowns:

s1 − s2 = k⁻¹(z1 − z2)       →   k = (z1 − z2) / (s1 − s2)
d = (s1·k − z1) / r

No discrete log is involved. signatures.py runs it on real secp256k1 with a synthetic key:

2. Two signatures, one nonce, on secp256k1 (synthetic key)
   r  = 0x07d30c8ddbf198787706c0cacca1a905d6d5fd42a900ad102e924859e61a7dac
   s1 = 0x7b6f8c2f72059175671d27d54515565cee8e497f81aac6fd15dbaeb62df412ec
   s2 = 0xd57e45139d9c51a228b351579907ea4b16366a8ba7c24c807c11e85edc2eb0f3
   k = (z1 - z2) / (s1 - s2)  recovered: True
   d = (s1*k - z1) / r        recovered: True

This is how Sony lost the signing key of the PlayStation 3: its firmware signatures used one constant k, and the fail0verflow group solved the two lines above in December 2010. The entropy series covered the Bitcoin version, where a weak random-number generator repeated nonces on Android wallets. The standard fix is RFC 6979: derive k from d and z with an HMAC, so the same message always gets the same nonce and different messages get unrelated ones. No random-number generator is left to fail.

Schnorr: the same idea without the inverse

Taproot added a second signature scheme to Bitcoin, Schnorr signatures as specified in BIP 340. The ingredients are identical: d, a nonce k, and R = kG. Only the mixing changes:

e = H(R, Q, message)
s = k + e·d  mod n              signature = (R, s)
verify:  s·G = R + e·Q

Verification is the same move as before: sG = kG + e·dG. On the toy curve:

3. Schnorr on the same curve
   R = k*G = (42, 36), Q = (25, 25), e = hash(R, Q, m) mod n = 8
   s = k + e*d mod n = 10 + 8*7 mod 31 = 4
   verify: s*G = (21, 25);  R + e*Q = (21, 25);  equal: True

The toy hash is SHA-256 reduced mod 31; BIP 340 uses a tagged hash and keys that carry only an x-coordinate. The difference that matters is that s is linear in d and k, with no inverse in sight. Signatures from several keys can be added into one, which is what multi-signature schemes such as MuSig2 do. The nonce rule does not change: two signatures with one k give d = (s1 − s2) / (e1 − e2).

What a signature leaves behind

Everything the verifier used is public, and the same algebra can be turned around. If Q is unknown and you hold (r, s) and z, the verification equation gives Q = r⁻¹(sR − zG). The signature supplies only R.x, so R is one of two points: the pair that Part 1 showed mirror each other, and a second pair if r wrapped past n. Each candidate gives a candidate Q.

That is how Ethereum drops the public key from its transactions, and it is why the moment you sign, an observer holds Q. Whether that matters depends on what an observer can do with it, which depends on the curve.

Part 3 compares the curves different chains chose.