Your address: Where your money is stored in the ledger
Every Bitcoin or fraction of a Bitcoin is “stored” in the ledger associated with a particular “address.” An address is a unique string of letters and numbers. Here’s an example of a real one I just grabbed from the Bitcoin blockchain using the blockchain explorer at www.blockchain.com
:
1L7hHWfJL1dd7ZhQFgRv8ke1PTKAHoc9Tq
Trillions of different address combinations are possible, so this address is fundamentally unique. All your Bitcoin is associated with one or more addresses. There’s nothing in the blockchain identifying you specifically, which is why Bitcoin is called pseudonymous it’s partly anonymous. Nothing in the blockchain says who owns what. However, the blockchain is also open and public. Anyone can look into the blockchain and see, within the ledger, how Bitcoin is being transferred from one address to another. So if you know who owns a particular address (as Bitcoin exchanges do, for instance; you’ll find out more about those in Chapter 3), you can see what that person did with their Bitcoin. That’s why it’s not completely anonymous.
Now, where do addresses come from? They come from wallets, which are software programs that generate addresses mathematically from a public key, which in turn was generated from a private key. In fact, wallets contain at least one private key, one associated public key, and one associated blockchain address. Which brings us to another subject you’re going to have to discover (just a little) about.
What’s the crypto in cryptocurrency?
The crypto in cryptocurrency refers to cryptography. So, what exactly is cryptography?
According to The Oxford English online dictionary, cryptography is “the art of writing or solving codes.” Wikipedia’s explanation is more complicated and more digital: “The practice and study of techniques for secure communication…cryptography is about constructing and analyzing protocols that prevent third parties or the public from reading private messages.”
The history of cryptography goes back at least 4,000 years. People have always needed to send secret messages now and then, and that’s what cryptography is all about.
Today’s cryptography, with the help of computers, is far more complicated than the ancient ciphers of the classical world, and it’s used more extensively. In fact, cryptography is an integral part of the Internet; without it, the Internet just wouldn’t work in the way we need it to work.
Almost every time you use your web browser, you’re employing cryptography. Remember the little lock icon, shown in Figure 2-2, in your browser’s Location bar?
FIGURE 2-2: Your browser’s lock icon means that data submitted back to the web server will be encrypted with cryptography.
The lock icon means the page is secured. When you send information from your browser to the web server (and receive information back), that information is encrypted — scrambled — so that if it’s intercepted on the hundreds or thousands of miles of Internet transmission between the two, it can’t be read. When your credit card number is transmitted to an ecommerce site, for example, it’s scrambled by your browser, sent to the web server, and then unscrambled by the receiving server.
Ah, so, the blockchain is encrypted, right? Well, no. Cryptocurrency uses cryptography, but not to scramble the data in the blockchain. The Bitcoin blockchain is plain text which is open, public, and auditable. Figure 2-3 shows you an example of a blockchain explorer designed for Bitcoin. Using a blockchain explorer, anyone can investigate the blockchain and see every transaction that has occurred since the genesis block (the first block of Bitcoin created).
FIGURE 2-3: An example of a blockchain explorer tool, found at https://live.blockcypher.com/btc/
.
ENCRYPTED BLOCKCHAINS
It is possible to build encrypted blockchains and encrypt data within a blockchain. For example, it is possible to create encrypted blockchains that obscure the transaction data, such as the Zcash blockchain, and some blockchains used for purposes other than cryptocurrencies may be encrypted. In general, though, cryptocurrency blockchains are not encrypted — the Bitcoin blockchain is not — so anyone can read the transactions stored within them.
No, the cryptography in cryptocurrency isn’t used to encrypt the data in the blockchain, it’s used to sign messages that you send to the blockchain. These messages are the ones that trigger transactions and updates to the blockchain ledger. We’ll explain this signing process in a moment, but to understand that, you have to understand a little about the magical keys.
Public key encryption magic
Public key encryption is a clever little trick created using digital cryptography. This type of encryption is all accomplished using hugely complicated mathematics — the sort of mathematics that even most people with advanced degrees in mathematics don’t understand, the sort of mathematics that has names like Carmichael numbers and Goppa codes, the sort of mathematics that we certainly don’t understand, and you don’t either (well, most of you, dear readers, don’t). But that’s fine; gravity isn’t well understood either, but we all use it every day. So, forget how this amazing stuff works, and consider instead what it is actually accomplishing. Peter likes to call this mathemagics; sure, it’s mathematics, but it’s amazing and almost nobody understands it, so it might as well be magic! Here’s how it works.
First, imagine a safe, with two keyholes and two associated keys. We’ll call one the public key, and one the private key. Now imagine that you put something into the safe and lock it using the public key. Once the door is closed and locked, the public key no longer has access to the safe; it can’t be used to unlock the safe and extract the item. The private key, however, will work. In fact, once the safe is locked, the only way to open it is to use the private key.
That’s weird enough, but it gets even stranger. This magical mathematical safe actually works both ways. You can also lock it with the private key, but after you lock it, you can’t use the private key to open the safe. Only the public key will open a safe locked with a private key.
Oh, and these two keys are magically associated. They work only with each other and no other keys. Private Key X will work only with Public Key X, and vice versa. You can’t lock the safe with Public Key X and then unlock the safe with Private Key W or Private Key K, for example.
Okay, same principle, but now think of electronic messages. You can lock an electronic message with a public key — that is, you can use a key to scramble, or encrypt, the message. That message may be an email or information being sent from your browser to a web server.
After that locked (encrypted) message is received at the other end (by the email recipient or the web server), only the private key can unlock it; the public key is useless at