Hackernoon logoWhy generate truly random private keys? by@vincentlg

Why generate truly random private keys?

Author profile picture

@vincentlgVincent Le Gallic

[spotted] 21 BTC (cumulative) sent to an address whose private key is compromised

Photo by Alex Chambers on Unsplash

To develop our applications, we are constantly handling authentication protocols (basic, digest, oauth, …). We even use hash functions and in 2016, when Apple required that all connections be in “https”, we could no longer ignore the main principles of symmetric and asymmetric encryption. And still …

When I generated accounts every 2 minutes while doing my tests on Ethereum, I had the impression to reserve myself addresses unnecessarily, I realize now that this reasoning is fundamentally wrong for several reasons.

First, the probability of a collision when creating an address is infinitely small, orders of magnitude are so huge that it is difficult to represent them. Then, even if two people tried to “brute-force” keys for 100 years, these addresses would have to be used on the Blockchain transactions for that to be relevant.

Photo by NeONBRAND on Unsplash

Conclusion, no reason to feel guilty if you generate thousands of addresses, consider rather that they already exist all but you can not control them.

So we have a system without storage / persistence that allows from a private key to generate a public key and an address. This is obviously a one-way system.

private key -> public key -> address

Do not try to hack it, there is no flaw in this system, it is both ultra secure and very “user friendly”. Without dependency (third party or hardware) I can sign transactions on the Blockchain with the only constraint, the knowledge of my secret code.

On the other hand, if your private key is compromised, a hacker can quietly take away your cryptos and you will not be able to do anything. If you find this shocking, make an analogy with your mailbox. When you send me an email, I know your public address (your email), imagine that your password is your date of birth (private key), the knowledge of these two elements is enough for me to hack your account.

Finally, the only weakness of the system (and it is often the case) comes from us. Without a centralized provider, we can not force users to generate their password randomly, we can only check that they respect a certain format.

Out of curiosity, @eric and I spent our Friday night coding a small script to generate addresses / private keys generated (deliberately) with very weak secret phrases.

On Bitcoin, after thirty lines of code, it was hard to believe but from our first tests, we came across addresses with transactions.

Code https://github.com/ericdesa/sentinelle

The idea is so simple that we are not the first profane hackers to have thought of this technique. If we look at the speed at which the deposited funds are stolen and the number of BTCs on thieves’ addresses, it is probably a very lucrative business.

example of compromised address

We followed with a little test on Ethereum (without conviction because key of 64 characters) and even finding, naively testing combinations, we find wallets on which people send Ethers (probably stolen in the seconds following the transaction) You will notice that these wallets are still used (less than 4 days).

Example of a passphrase tested: 0000000000000000000000000000000000000000000000000000000000000001
code available here https://github.com/vincentlg/ethSentinelle/blob/master/index.js
https://etherscan.io/address/0x2b5ad5c4795c026514f8317c7a215e218dccd6cf

If you are creative and want to compete with other thieves who have to scan these addresses, the code is available on Github (links above). With a little inspiration and luck, you may be the first to crack a wallet with 25 BTC … Does a weak password justify a theft? Up to you.

For my part, I hope i made you aware of the importance of generating its private keys seriously, using really random protocols and especially not online … Imagine a diabolical service, which would allow you to test your ideas of weak secret phrases in hope to crack wallets and who answered you

“Failed unfortunately, but try again …”

and that, even if successful ;)

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.