Last month, hackers managed to steal more than 7,000 bitcoin from crypto exchange Binance, the world’s largest by volume. This week we got to know about an old bitcoin exploit that could target certain wallets if used correctly. The only problem is that not many bitcoin companies/wallets will re-use values these days when signing transactions, but people who are creating new copies of old coins and wallets generally don’t know about this.

The method uses transactions with a broken random number generator (string). These addresses re-use certain values in a transaction due to poor knowledge, programming errors, or a broken random number generator.

If you take a look at this transaction:…0e3b29c4b1

There are two inputs and one output in this script. Inputs are pointers to outputs of previous transactions. Outputs are, at the basic, an amount and an address.

Taking a closer look at the inputs of these scripts we notice that they are similar.

1. ScriptSig:


[30440220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843 ad1022044e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e01]


[04dbd0c61532279cf72981c3584fc32216e0127699635c2789f549e0730c05 9b81ae133016a69c21e23f1859a95f06d52b7bf149a8f2fe4e8535c8a829b449c5ff]

2. ScriptSig:


[30440220d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f84 3ad102209a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab01]


[04dbd0c61532279cf72981c3584fc32216e0127699635c2789f54 9e0730c059b81ae133016a69c21e23f1859a95f06d52b7bf149a8f2fe4e8535c8a829b449c5ff]

The beginning of the scripts contain the signatures (defined as ‘r’ and ‘s’). The end of the script is the hex public key.

So we have:

r1: d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1
r2: d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1

s1: 44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e
s2: 9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab

It turns out that the r values in the scripts are exactly the same. This means we can derive the private key.

Bitcoin Private Key = (z1*s2 - z2*s1)/(r*(s1-s2))

We have the r and s values, now we need to find the z1 and z2 values. For that navigate to:

Enter in our transaction ID:


Scroll down to find the z values.


We find:

z1 = c0e2d0a89a348de88fda08211c70d1d7e52ccef2eb9459911bf977d587784c6e

z2 = 17b0f41c8c337ac1e18c98759e83a8cccbc368dd9d89e5f03cb633c265fd0ddc

Bitcoin uses an elliptical curve for generating public keys. The order of the curve is secp256k1.

p= parameter for the secp256k1 curve. So;


We will need to create a finite field for the calculation.

K = GF(p)

Now that we have all the information we need, we can run our calculations.

We’ll use Sagemath:

I will be using the cloud version. Make sure you input all of our equations:

r = 0xd47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1
s1 = 0x44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e
s2 = 0x9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab
z1 = 0xc0e2d0a89a348de88fda08211c70d1d7e52ccef2eb9459911bf977d587784c6e
z2 = 0x17b0f41c8c337ac1e18c98759e83a8cccbc368dd9d89e5f03cb633c265fd0ddc

K = GF(p)

K((z1*s2 - z2*s1)/(r*(s1-s2)))

Click run:

11 1

The calculation outputs:


Now we will convert it from decimal to hex. You can do so here:…o-hex.html

Our private key in hex is:


From here we can convert it to a WIF (wallet import format). This represents the private key!

A WIF private key is a standard private key, but with a few added extras:

  1. Version Byte prefix - Indicates which network the private key is to be used on.
0x80 = Mainnet
0xEF = Testnet
  1. Compression Byte suffix (optional) - Indicates if the private key is used to create a compressed public key.
  1. Checksum - Useful for detecting errors/typos when you type out your private key.

Go here:

Enter in our hex private key.

12 1

Our private key in WIF is: