How Bitcoin Works, Explained for English Majors.

How Bitcoin Works, Explained for English Majors.

A bitcoin is essentially a large number. A very large number. If you know the number, the bitcoin is yours to spend. If someone else knows the number, they can spend the bitcoin and your money is gone.

Secret Password

So the very large bitcoin number needs to be kept secret. Bitcoin owners call this your private key. We will call it your “secret password”. You can assign your own secret password as long as it has the required number of digits. Most people get a random number assigned as their secret password. The problem is that it is hard to remember. If you forget your secret password, there is no way to recover it. So special care must be given to writing down or save your password somewhere safe, but also somewhere where you have access to it at all times. Remember, you never tell anyone your secret password otherwise they may use it.

The bitcoin program takes the secret password and does a calculation on it resulting in another number, which is unique to your secret password. This other number is your public key. We will call it your “account number”. Anyone can know your account number. In fact, they need to know your account number to send money to you, or to verify that you sent them money. Some people post their account numbers on the web and say "please send me a tip". It is totally safe to give this number to everyone.

One Way Streets

So far so good? The next step in understanding bitcoin is to understand the nature of the calculation used in bitcoin. Most calculations are two-way streets. If you know the starting numbers, you can calculate the ending numbers, and if you know the ending number, you can work backwards and figure out the starting numbers. These two-way streets are reversible mathematical calculations.

But there is a branch of mathematics that deals with one-way streets. You can easily go from start to end, but you cannot go from end to start. They are irreversible calculations. In real life, some things we do are reversible. For example, if I use my coffee mug, I can wash the mug and it is back in its pristine original state.

But some things in life are not reversible. It is easy to dump a cup of sugar in a pail of water but it is hard to get the sugar back out. Hard, but not impossible. I can boil off the water. It would take time and energy but it can be done. But suppose I dumped a cup of sugar into the ocean. Then it would be totally impossible to recover. The branch of mathematics called cryptology is all about irreversible calculations. For instance, in 1942 the British Air Force writes a message to their spies in Nazi Germany. The process of encrypting the message is relatively easy, but decrypting without the secret code is impossible.

So like sugar, it is easy (for a computer) to take the secret password and calculate your account number, but it is very, very hard to take your account number and calculate your secret password. Very hard in this case means all the biggest computers working for thousands and thousands of years. Bitcoiners call this kind of one-way calculation a "hash". Maybe it is because when you buy a can of corned-beef hash at the supermarket, you can never really be sure what kind of meat went into it. It is easy to grind the meat. But it is impossible to ungrind. So if a secret password is hashed, the computers have no way of working backwards efficiently.

The Three Hashes

In bitcoin there are three different kinds of hashes. The first hash takes a secret password and, using a one-way hash, calculates your account number. You must have an account number before you can do anything else. Then you fund the account. Either someone pays you in bitcoin or you exchange dollars for bitcoin. When they send you bitcoins, you give them your account number and presto, the transfer is made. Lets look at this in detail.

Suppose you wish to buy a cup of coffee at Starbucks using bitcoin. The second hash, takes your secret password, the amount of money you want to spend, the address to where you want to send it, and the date/time now, and calculates, one-way, a number that we will call "your signature". You flash your signature to the barrister at Starbucks and the Starbucks computer calculates the second hash, the easy way, and verifies that you own the bitcoin, have money in your account, and transfers the money. The signature contains the date, time, amount, the "to" account number and the "from" account number, so that Starbucks cannot alter the transaction, to increase the money paid them, or use it again, or send the money to a different person.

The third hash is used in the recording of transactions in the transaction ledger. Bitcoin processors call this the Blockchain. This is a globally distributed list of all transactions. Everybody has a copy. Suppose I use a text editor to alter the list to add some money to my account. Or delete some transactions where I spent money. How do you prevent people from making up their own list of transactions that favors them? How do you make one official copy that nobody can alter? The answer is the third hash.

The Brute Force Method

Suppose you have a combination lock at the gym. You forgot the combination and your things are in the locker. You cannot look inside the lock to see what the combination is. Maybe you could if the lock were made from clear plastic. But it is not. There are four numbers on the lock, so you try combination 1-1-1-1. Then you try combination 1-1-1-2. And you do that all the way until you try combination 9-9-9-9. Maybe you get lucky and the combination is a low number. Maybe it is a high number and it takes a very long time.

In a similar way, the hash cannot be reverse engineered, so to “solve” it, computers try numbers in order. But many computers can split up the task to make it quicker. For example, a computer in Sweden might start with 1-1-1-1 and one in Germany might start at 8-8-8-8. And they have a race to be the first to find the solution.

In the Bitcoin world there are millions of computers sharing the task. Most of the bitcoin processing computers are data centers with thousands of racks of computers, each rack having many CPUs, and each CPU is specially designed to work these kind of calculations quickly. One estimate says if all the computers processing bitcoin were laptops, it would take 50 billion laptop computers to match the processing power of the bitcoin network.

Groups of Transactions

Assume in a particular ten minute period there are 1,000 transactions made worldwide in Bitcoin. The computers processing bitcoin take these 1,000 transactions call it a "block". Then they do something that is called “solving” the block and come up with one number that makes everything fit in a mathematical way.

The equation that they solve is the third hash. And they solve it backwards, that is, the hard way by going through all the combinations.

What they are solving includes all the data from the 1,000 transactions in the block. The solution is the third hash. The third hash requires an enormous amount of calculations and takes a long time to process because it is so large and extremely complex.

They are spinning through all the numbers in succession until they find the right combination. This is called the Brute Force method of solving. This continues with computers all over the world until someone, somewhere gets lucky and solves the block. Is this efficient? No, but purposely so. The existence of the solution proves that a lot of computer work was done to achieve it. They call this the “proof of work”.

If the proof of work is large enough, then only someone with a big enough computer and enough time can alter the transaction ledger. And nobody has a big enough computer or enough time.

Knitted Together.

Bitcoin transactions are grouped in blocks, and the blocks are knitted together, to form a Blockchain. Blockchain means a chain of blocks. How are they knitted together? In my above explanation of the third hash, I neglected to mention that the third hash from the block before is a starting ingredient in the next block.

So block 2 depends on block 1 and block 88 depends on block 87, block 87 depends on block 86, etc. If you wanted to recreate the transaction ledger, with altered transactions, you need to start at day one and go forward, using again all the computer power that went into bitcoin in the years from its creation.

The blockchain is actually a beautiful piece of computational art. It is easy to verify the solution for any row. So everyone can test if they have a valid transaction ledger. It is like a knitted sweater. You can look at it and see if any stitch is out of place, and it is a proof of work, you can admire all the resources that went into it.

And when you grasp all the computational power that went into the globally distributed ledger, you can feel confident that nobody messed with it, that your money is protected by mathematics.

The first hash gives your account number, the second hash gives your signature and the third hash keeps the transaction ledger from being altered.

You can take comfort in knowing that the bitcoin computer network is the largest network on the planet and growing. Each time someone adds another computer to the bitcoin network, bitcoin becomes safer still.