Knowledge Base · general

ECDSA Nonce Reuse

generaltechnique notetechniqueecdsa-nonce-reuse

Reusing the per-signature random nonce k in ECDSA leaks the private key from two signatures.

How it works

  • From two signatures (r,s1),(r,s2) over hashes z1,z2: k = (z1−z2)/(s1−s2) mod n.
  • Then recover the key: d = (s1·k − z1)/r mod n.
  • Any visible reuse of r is the smoking gun.

Detection & defence

  • Use deterministic nonces (RFC 6979) or a well-seeded CSPRNG.
  • Rotate keys if a nonce is ever suspected of repeating.