Biased nonce lattice attack (hidden number problem)
Recover an ECDSA key from many signatures whose nonces leak only a few bits, by reducing the hidden number problem to a lattice with LLL.
Open in ctfpalNonce reuse is broken by two equations. Nonce bias - where each nonce is merely a bit short, or shares a few known high bits - leaks nothing to algebra but everything to lattices. This is the attack behind several real-world wallet key recoveries, where signing devices produced nonces with a handful of predictable bits.
From signatures to a lattice
Each signature gives s = k^-1(h + r*d) mod n, which rearranges into k = s^-1*h + s^-1*r*d. If k is known to be small - say under 2^248 on a 256-bit curve because the top 8 bits are zero - then each signature is a statement that a particular linear function of the unknown d is unusually small. Stack many such statements as rows of a matrix and the true d corresponds to a short vector in the resulting lattice. LLL finds it.
- Bits leaked versus signatures needed - roughly, the fewer bits you know, the more signatures. 8 known bits needs a few dozen; 4 bits needs low hundreds; 1 bit needs thousands and careful lattice construction.
- All signatures must use the same private key - the whole point is that
dis the shared unknown. - Scaling matters. The lattice basis must be weighted so the target vector is genuinely the shortest; a badly scaled basis returns a short vector that is not your key.
Related tools
ECDSA nonce reuse private key recovery
Recover an ECDSA private key from two signatures that reused the same nonce - the flaw that broke the PlayStation 3 and countless wallets.
Discrete logarithm solver
Solve discrete logs with baby-step giant-step, Pollard’s rho, and Pohlig-Hellman - the last of which breaks any group with smooth order.
Linear congruential generator predictor
Recover the modulus, multiplier, and increment of an LCG from a handful of consecutive outputs, then predict every future value.
RSA decryption and attack runner
Paste n, e, and c and let ctfpal choose the attack: trial division, Fermat, Pollard’s rho, Wiener, common modulus, or Hastad broadcast. Arbitrary-precision, in-browser.