03 - Public Key Cryptography

Public key cryptography is powerful in general because it is one of the few things on the planet that can create an asymmetric power imbalance. This means that, even if the largest corporation or government were to focus every available resource into figuring out a certain individual’s private key, they will not be able to do it. Isn’t that crazy!? This asymmetric power imbalance is so dramatic that in the 1990s, world governments fought against the use of public key cryptography. The argument was, because public key cryptography essentially cannot be broken, it represented a critical threat to the national security of governments like the United States. We’ll discuss this history more in a following section, but know that at one point using this technology was almost illegal!

Public key cryptography is powerful for blockchain specifically because it allows us to prove a message has been sent from a certain person holding a specific private key. This is a step in the direction of establishing identity in a peer-to-peer way. Remember, a blockchain protocol is trying to provide what banks or governments have previously provided but without those institutions as intermediaries. What public key cryptography does is mathematically prove a certain person holds a certain key.

Consequences

However, there’s a big issue here. There’s no way to determine who holds the key, just if they have the key. We are assuming the private key equals the owner of the assets, but what if someone steals your private key? This is a big security and user-experience issue for people coming into the blockchain and cryptocurrency world.

As consumers, users are probably used to being able to reset their passwords, recover their funds if there’s fraud, or at least reach out to a service and get assistance in case of trouble. At its most basic, with users handling their own private keys, almost all of this disappears.

Even more troubling, regardless of the amount of messaging a user receives about protecting their private keys, many may not understand there is no safety net until it is too late. And for those users who are experienced, there are so many bad habits we’ve all developed as consumers which are hard to break.

All this to say: Not trusting is expensive. Please be aware of how expensive it is, not only for yourself, but also for your users. Luckily, at the end of this section, we’ll walk through some basic security considerations that anyone in the crypto space should adopt from Day 1

Okay! Parental lecture over, stepping off of soapbox, and now time to play with some public keys cryptography!

Moar on Keys

There are a ton of additional resources for public key cryptography, so we’re going to break them up into different sections: General Public Key Cryptography Resources, Blockchain / Ethereum-Specific Public Key Cryptography Resources and Advanced Public Key Cryptography Resources.

General Public Key Cryptography Resources

Know that in these examples, you will meet some lifetime friends, Alice and Bob. They are the most absolutely unimaginatively, Eurocentric named parties in every cryptographic key exchange (rather than using A and B). Please, please if you’re ever teaching this to someone else use a more interesting name than Alice and Bob, like Akash and Basilia. But, it is the common way to discuss it and perhaps there’s value in that commonality across cultures.

Blockchain / Ethereum-Specific Public Key Cryptography Resources

Now that you have an understanding of public key cryptography generally, let’s dive into how it is used in blockchains, specifically Ethereum. The following links will mainly show how private keys are used to generate Ethereum accounts, which then become a stand-in for identity on the Ethereum network. Note that all Ethereum addresses start with the first two characters 0x, which is not actually part of the address but rather a prefix used to let programs know the address is coded in hexadecimal format.

Advanced Public Key Cryptography Resources

  • Coding Problem Set: Cryptopals This is an extremely advanced problem set series discussing applied cryptography generally. Not for the faint of heart!