Bitcoin, dogecoin

Here is a long but completely simple article for explaining how Bitcoin works. A word of caution- this is a bit of a long read. Albert Einstein said, “Make everything as simple as possible, but not simpler”. I’ve tried my best to do just that.

Imagine that someone wants to give you some tokens in exchange for something of value that you provide them. How do you protect yourself from being cheated, how do you guarantee that those tokens will remain yours? With physical tokens like cash, metal, or gems, it’s easy: it can only exist in one place at a time, so as long as you’re holding onto it, it can’t be anywhere else.

But electronically? Things which exist only electronically can be trivially duplicated. So if someone is sending you a digital token online, how can you trust that you are now the only unique holder of it, and it isn’t simultaneously being copied and sent to other places online?

Banks and Bitcoin

The traditional solution is to defer verification to a central authority, usually a bank. The bank keeps a ledger, a master database of who owns what. That person would notify their bank that they’d like to transfer some tokens to you, the bank would check their ledger, verify that they have it, then create a new entry into the ledger recording the transfer. If that person were to try and send the same tokens to someone else later, the bank would say no, you can’t do that.

This works well in protecting you from needing to trust the other person, but it introduces a third party into the transaction, the bank. A bank which needs to monitor and track what you have, always stands between you and the person you’re sending tokens to, and who has the power to deny or even reverse transactions, freeze or seize tokens, and edit the ledger as it chooses.

How can you create a ledger for a digital token which cannot be duplicated or counterfeited, which can only exist in one digital pocket at a time, which can be transferred from user to user freely but cannot be double-spent, where no single entity needs to be trusted with unilateral power over the books?

Proof-Of-Work Blockchain

What Nakamoto proposed is something called a Proof-Of-Work Blockchain. A blockchain is a special type of ledger maintained by a decentralized, trustless swarm of competing agents, which will nevertheless converge upon one single un-alterable consensus ledger of transactions because of the rules about how new entries to the ledger must be written.

In 2008, Nakamoto published their paper, and in early 2009 they released the first public blockchain onto the internet, and the tokens of this blockchain are called Bitcoins.

There are two key concepts you need to understand: 1. Hashing algorithms, and 2. Public-Private Keypairs. Let’s go over them now.

Hashing Algorithm

A hashing algorithm is a bundle of math which functions like a precise woodchipper. If you feed something in, it takes your input and shreds it into a string of digital static called a hash. If you feed the same thing in, you’ll always get the same string out. If you change the input even a tiny bit, the hash that comes out will be completely different. And it’s impossible to take a hash and use it to reconstruct the original input.

A Public-Private keypair is a secure way to digitally prove your identity and ownership. The Public key can be disseminated widely, and the Private key is kept secret by the owner. The Private key can be used to prove that you’re the owner of the Public key.

Blockchains

Like any bank’s ledger, the Blockchain is a database, a huge list of public wallet addresses (corresponding to public keys) along with data on how much bitcoin each one contains. It also contains the complete transaction history of every single transfer of bitcoin from one address to another since the blockchain was first created in 2009. This file is massive- over 300 gigabytes as of Jan 2021. Each new batch of transactions added to this database is called a block, and each block is built off the previous one like links in a chain.

However, unlike the ledger of a bank, adding a new batch of transactions to the Blockchain ledger is an intentionally hard process, and the deliberately wasteful difficulty of doing so is the key to its security.

Suppose you wanted to receive bitcoins from someone. You’d randomly generate a public-private keypair, and you’d give them the public key you just generated. They would have the private key for their wallet, which exists on the blockchain and is registered as having some amount of bitcoin, and they would use their private key to transmit a message, “hey, wallet XYZ transfers 0.22524511 bitcoin to wallet ABC, here’s proof that I’m the owner of XYZ. By the way, I’m including a tip of 0.00005000 bitcoin to the Miner who processes this”.

What is a Mempool?

This message goes to what is essentially a public noticeboard (called the mempool).

Then, the Bitcoin Miners come in. Bitcoin Miners are the people (technically, the computer systems they set up) who monitor the mempool and are in constant competition to luck out and become the author of the next block. The reward for doing so is that, in addition to the tips collected from all transactions, each block written allows the author to declare the creation of a new public wallet address which has coins from nowhere, to which the miner holds the private key.

A block might look like,

The previous block was block #149 This is block #150 XYZ transfers 0.22524511 coins to ABC and 0.00005000 coins to MYN SRM transfers 15.4250000 coins to KJQ and 0.00004500 coins to MYN JOE transfers 0.00752000 coins to LEA and 0.00002200 coins to MYN The new address for this block is MY2, which now contains 50.00000000 coins End of Block #150 Zombie Pirate Party Monkey

You might have 2 questions in mind right now:

What’s stopping a miner from just writing blocks as fast as they want and minting coins for themselves as fast as they’d like?

Hashing

What’s the deal with the last part of that block? The answer to both questions are the same, and they’re related to Hashing. If you take the entire block and shove it through a hashing algorithm, you’ll discover that the hash which comes out looks extremely unusual.

This is the hash for the real block #150 on the actual blockchain- 000000009ca75733b4cf527fe193b919201a2ed38c9e147a5665fdfade551f4d

Notice something? The critical rule of Bitcoin mining, which stops miners from just writing as many blocks as they’d like as fast as they’d like, is this: the hash of each block must start with a certain amount of zeroes.

In order to write this block, the miner first writes a draft: “The previous block was #149, this is block #150, people sending coins to each other, tips go to my wallet which is here, and here’s my new wallet with 50 coins I want to add to the blockchain”, and then they hash it. It probably won’t start with the needed amount of zeroes. So they add a random bit to the end and hash it again. Still no. The miner will keep throwing different random bits into their draft block, billions of times per second until, by pure luck and brute force, they hit upon a random string which makes the block pass.

“Eureka! Here’s Block #150!” they announce, broadcasting the new block to other miners. The other miners, busy with their own billions of guesses per second, spare a single hash cycle checking out this #150, confirm that it checks out, drop their own personal drafts of #150, adds this #150 to their own personal copies of the blockchain and start working on block #151, hoping to write the next block themselves.

As the miners spread word of the new block #150, you’re satisfied to see that person’s transaction now recorded onto this latest link of the blockchain.

Think about what would need to happen if, thirty minutes later, the person who sent you those coins wanted to take it back, erase that record, and spend it elsewhere.

They would have to write an alternate block #150, one that didn’t include their transaction to you. In order to do that, they would have to make trillions of guesses themselves before they found a random string that would make it hash properly. Then, they’d have to write an alt-#151, alt-#152, and so on. Meanwhile, the majority of the miners have already published block #153 and are now working on block #154, and nobody would accept their alt-#150 because everyone is already racing to write #154. The only way for a bad actor to reverse and double-spend a transaction which has already been written would be to create an alternate chain longer than the dominant one, and doing that would require commanding more computer power than the rest of the network combined. Good luck.

Cant be Duplicated or Counterfeited

And that’s how you create a digital token that can’t be duplicated or counterfeited, can only exist in one place at a time, whose supply is finite, which can be sent freely from any address to any other, and is secured not by trusting a third-party authority, but by math.

This is what Bitcoin is, and what it continues to be today.

Built around this are the far more messy human questions of, what is it worth? How much are people willing to buy and sell it for today, and what price will they pay for it tomorrow? These questions and the rancid sewers of discussion around them are beyond the scope of this explanation.

Bitcoin Has Value?

Bitcoin came into existence early in 2009, and at first it was largely just a curiosity and a plaything for cryptography nerds, computer scientists, and economic libertarians. It was a neat toy, but the question at the time was, “Okay, it’s cool, but does this stuff actually have any value at all?”

Eventually, on May 22, 2010, a Florida man paid another person 10,000 bitcoins for them to order him two Large pizzas from Dominos. With this, they became the first two people in history to believe that the answer to that question is: Yes, it does.

So far, people have not stopped believing that… yet.