This repository implements a Python function recover_private_key
that recovers the private key from two different signatures that use the same random nonce
First, note that the integer order
# Represented as hex value.
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414
# Represented as integer value.
n = 115792089237316195423570985008687907852837564279074904382605163141518161494337
Let's assume that
and
We can solve for
Eventually, we can now plug
The function
recover_private_key
uses the last equation in conjunction with modular arithmetic properties to recover the private key.
- Elliptic Curve Digital Signature Algorithm
- RFC 6979
- A Glimpse of the Deep: Finding a Creature in Ethereum's Dark Forest
- How Hackers Can Exploit Weak ECDSA Signatures
- ECDSA Nonce Reuse Exploit Example
- Identifying Key Leakage of Bitcoin Users
- How Do You Derive the Private Key From Two Signatures That Share the Same
k
Value?