Couldn't Everybody Type in Random Private Keys and Steal Funds?
Last updated: 2019-07-08
Yes, but finding an account with a balance would take eons ... so ... no.
Ethereum is based on Public Key Cryptography, specifically Elliptic Curve Cryptography, which is also used widely outside of Ethereum. Most servers are protected via ECC. Bitcoin uses ECC, as well as SSH, TLS, and a lot of other stuff. Ethereum specifically utilizes 256-bit keys, which are stronger than the popular 128-bit and 192-bit versions that are considered secure by experts.
In this, you have a private key and a public key. The private key can derive the public key, but the public key cannot be turned back into the private key. The fact that specialists who guard the world's secrets are using this cryptography means that if there was a way to go from public key to private key, your lost Ether would be the least of everyone's problems.
Now, that said, YES if someone else has your private key, then they can indeed send Ether from your account. Just like if someone had the password to your email, they would be able to read and send messages from your account, and if they had the PIN to your bank account, they could make transfers. For added security, you may want to download the Keystore version of your private key, which is the private key that is encrypted with a password. This is like having a password that is also protected by another password.
And YES, in theory, you could just type in a string of 64 hexadecimal characters until you got one that matched. In fact, smart people could write a program to very quickly check random private keys. This is known as "brute-forcing" or "mining" private keys. People have thought about this long and hard. With a few very high-end servers, they may be able to check 100k keys / second. However, even checking that many per second would not yield positive hits at a rate that would make the cost of running those servers even close to worthwhile—it is more likely that you and your great-grandchildren would die before getting a match.
If you know anything about Bitcoin, this will put it in perspective:
"To illustrate how unlikely this is: suppose every satoshi of every bitcoin ever to be generated was sent to its own unique private keys. The probability that among those keys there could be two that would correspond to the same address is roughly one in 100 quintillion."
"These numbers have nothing to do with the technology of the devices; they are the maximums that thermodynamics will allow. And they strongly imply that brute-force attacks against 256-bit keys will be infeasible until computers are built from something other than matter and occupy something other than space."
Of course, this all assumes that keys are generated in a truly random way and with sufficient entropy. The keys generated here meet that criteria, as do Jaxx and Mist / Geth. The Ethereum wallets are also all pretty good. Keys generated by brainwallets are not good enough, as a person's brain is not capable of creating a truly random seed. There have been a number of other issues regarding lack of entropy or seeds not being generated in a truly random way in Bitcoin-land, but that's a separate issue that can wait for another day.
- BIP-39s (mnemonic phrases & Ledger hardware wallets)
- How does it ensure that it doesn't give different people the same key?
- Not all private keys are valid on the curve