How Does Bitcoin Work?

Posted in   Bitcoin   on  September 11, 2022 by  Money Bren0

Nothing in this article is financial advice. The writer is not your financial advisor. Investing contains risk and you can lose money. Consult your own professionals before making investment decisions. This article may contain affiliate links. 

You’ve been hearing about Bitcoin for years now, and still have no idea what it is or how it works.

You Google it.

You see words like mining, hash rates and algorithms.

You probably come across the word blockchain.

They try to explain it.

It doesn’t make sense.

Doesn’t matter.

You just buy it and hope it goes up.

Yolo.

Yes, we all did that.

Then I realised, you can’t do that forever.

Eventually, we need to learn how this really works if we want to make good investment decisions.

That’s exactly what I did.

I’ve spent the last few years studying Bitcoin and how it works.

Below is my best explanation, broken down in a way that normal people like you and I can (hopefully) understand.

It’s long, and you might need to read it twice, but I hope it helps you as much as it’s helped me!

WHY BITCOIN? WHAT IS ITS PURPOSE?

Bitcoin is a currency.

It’s money.

It only exists digitally.

It’s a bit like email for money.

Mail exists physically, email exists digitally.

Dollars exist physically, Bitcoin exists digitally.

Think about how mail works.

Everybody has a unique street address to receive mail, and a unique email address to receive email.

Now think about how money works.

We have a unique bank account number to receive dollars.

Bitcoin works similarly.

We have a unique Bitcoin address to receive Bitcoin.

If you want to pay someone, you can send Bitcoin to them over the internet to this address.

Usually it arrives in just a few minutes, and only costs a few cents.

This is the first thing that sets Bitcoin apart from your regular bank.

It allows you to send money very quickly, anywhere in the world, for very low cost.

The second difference is it’s universal.

Anybody can have a Bitcoin address in just a few seconds, whether they’re in Japan, Iraq, Australia, even Antarctica.

It doesn’t matter how old you are, your race, religion, credit history, how rich or poor you are.

All you need is an internet connection.

THE PROBLEM BITCOIN SOLVED: TRUST

People have tried to make digital currencies before.

There have been countless times when people used digital currencies as real money (i.e. to buy things).

You might have seen this several times in your own life – whether it’s the digital currency inside Clash of Clans or Candy Crush, in World of Warcraft, Farmville, even Ping on Trademe is a form of digitalised currency.

However, none of these could ever succeed in becoming mainstream currencies in the past, and the reason is an absence of trust.

Let’s take Ping for example.

Ping is Trademe’s very own digital currency. You deposit money into your Ping wallet, and then you can use your Ping dollars to instantly send or receive funds on the website whenever you buy or sell something, so you don’t need to wait 24 hours for a bank transfer.

Now imagine Trademe offered you a deal – they say can buy Ping dollars for 90 cents on the dollar.

Meaning if you deposit 90 cents, they’ll credit your Ping account with a dollar.

That’s a good deal. If you use Trademe a lot, you’re basically getting an instant 11% return on your money.

But the problem is trust.

You could put in $20,000, and Trademe will give you $22,222 Ping dollars.

But how do you know those Ping dollars will still be there next week?

How do you know Trademe is not in financial trouble, and tomorrow they won’t go bankrupt?

If Trademe went bankrupt tomorrow, this $41 in my Ping account would be gone. Ping wouldn’t exist anymore.

The fact is your Ping dollars could become worth zero at any time, and there’s nothing you can do about it.

In fact, this is the main problem with all currencies. Trust.

For instance – how do we know the NZD is worth anything? How can we trust the government behind it? How do we know they won’t just print zillions of it tomorrow, and all our NZD will become worthless, just like what happened to Zimbabwe dollars and Venezuelan bolivars?

The only reason the NZD functions as a currency is because the NZ government has earned enough trust from the people that use it.

However, most digital currencies aren’t able to earn this level of trust. Would you trust Trademe with your life savings in Ping dollars if they offered you 30% interest?

No.

You don’t trust them enough.

The reason Bitcoin has lasted so long is, it finally found a way to solve the problem of trust.

The way it solves trust is through a technology known as blockchain (we’ll discuss blockchain mechanics further below, keep reading).

Blockchain offers many unique things that make it trustless.

The first is decentralisation.

No one entity controls a blockchain. The Bitcoin blockchain is governed by consensus of the people who use it and hold it. Therefore, it’s self-serving in that the people who use it are naturally motivated to do what’s best for it. Decentralisation also means it is immune to censorship or shutdown.

The blockchain also offers transparency. 

The Bitcoin code is public and open source. It means anyone can read it, check it, audit it, and suggest improvements to it.

Note how different this is to another digital currency, such as Ping, or even the currency in a game like Clash of Clans. Nobody knows anything about it. The owner of Clash of Clans can at any time create a billion new coins, nobody knows what the total supply is, nobody knows if the app will just disappear tomorrow. Obviously, Clash Of Clans was not trying to create a currency that could be used in a real world, but this still demonstrates why a digital currency has never been possible before now.

The blockchain itself is also public and everyone who has an internet connection can see it.

If Fred tells you he sent you $10, the entire world can check if he really did.

It is impossible for Fred to lie about paying you, because the transaction is published for the entire internet to see.

By being totally transparent and public, it’s difficult for anyone to be fraudulent.

The final way the blockchain solves the issue of trust is through its peer-to-peer nature.

Bitcoin does not require banks and governments to operate.

Senders and receivers now only need to deal with each other.

Now all that sounds great, but what is happening under the surface that allows Bitcoin actually do all of this?

Let’s take a look below.

HOW IT WORKS (FOR THE CONSUMER)

For the consumer, Bitcoin works just like internet banking.

You deposit Bitcoin into your Bitcoin address.

When you want to pay someone, you enter their address and click Send.

The transaction gets sent to the network, where hundreds of “miners” around the world process it, confirm it, and it gets spit out the other end.

It’s just like money.

As we mentioned earlier, the difference is that it runs peer to peer.

No third parties are involved.

How does this differ from regular money?

With regular money, third parties are always involved. When you send NZD to someone, you must send it through an institution.

You set up an account at Kiwibank, you give money to Kiwibank to put in your account, and then you tell Kiwibank to send it to Fred.

If Fred banks with BNZ, then Kiwibank contacts BNZ and tells them to put that money into Fred’s account.

Once it arrives, BNZ alerts Fred that he’s got money, and he goes to the bank to retrieve it.

As you can see, there are four parties involved here – you, Kiwibank, BNZ and Fred.

If you were sending this money overseas to Japan or Europe, there would probably be five or six entities, plus another hundred dollars in fees and a few phone calls and signatures.

Ultimately this means banks have absolute control over who and who isn’t allowed to send and receive money.

It also means, if you ever want to send NZD digitally to anyone, you must put your trust in a third party, such as a bank.

It is impossible to do it without one.

In most cases, this is not an issue.

I doubt you’ve ever received your paycheck in NZ dollars and thought, “Oh gosh I’m worried the NZ government might go bankrupt tomorrow, I better change this NZD into gold bars!”

The system works seamlessly because it is administered by a democratically elected government which has developed a financial system that is robust and has built up a certain level of trust.

But, it also means the system is not trustless. You are still required to put trust in a single entity.

This is also why banks around the world provide guarantees as well as governments providing guarantees as well as regulatory institutions overseeing the banks and so on – because they know trust in the system is everything.

Without it, you can see what happens by studying the history of places like Zimbabwe, Cyprus, Ecuador and Argentina.

Bitcoin removes all those intermediaries.

When you send Bitcoin to Fred, nobody is involved except you, Fred and the internet.

However, as we said, the core problem is still trust. Even if you don’t need to trust a third-party institution, you still need to trust the Bitcoin protocol itself.

How does Bitcoin earn this trust?

How can people trust the “legitimacy” of this money, as much as the legitimacy of government currencies?

HOW BITCOIN CREATES TRUST AND VALUE

The problem with most digital currencies before Bitcoin is, they were created out of thin air.

Go back to the Clash of Clans example.

The coins in Clash of Clans are infinite.

The CEO of Clash of Clans can simply push a button, and a billion more coins appear.

How can it be worth anything, if you can just create an infinite amount?

We could go even further and use the Ping example.

Imagine if Trademe users collectively deposit $50 million into Ping.

Trademe goes and spends all that money on, I don’t know, donuts.

This might not be a problem, because at any one time, Trademe users might only be withdrawing $1 million or $2 million at any one time.

But let’s say, one day Ping users try to withdraw $20 million.

Trademe only has $1 million the bank.

They gave you imaginary Ping currency that only exists on a screen, while spending all your real money.

See the problem?

This is why digital currencies must be trustless.

This is the key reason digital currencies have never succeeded.

How can they be worth anything if we don’t know what’s real and what’s not?

The blockchain solved this issue.

Bitcoin is not created out of thin air.

It is mined.

Just like mining gold in the real world requires energy, mining Bitcoin on the blockchain also requires energy.

Let’s say Fred wants to mine Bitcoin.

He fires up his computer and downloads the Bitcoin client (which is open source), and starts mining.

Fred’s computer does two things for Bitcoin.

First, he’s maintaining the network. By running the Bitcoin software on his computer, he serves as another user securing the Bitcoin database, also known as a node.

This contributes to the decentralisation of Bitcoin, like we explained before.

The more Bitcoin nodes that are online, the more decentralised and robust the network becomes.

No one entity is responsible for keeping the network online. It is maintained by consensus of the people who actually use it.

Now your next question might be, why would Fred want to spend all this electricity on securing the Bitcoin network?

Bitcoin understands this. It understands Fred needs an incentive. Humans are greedy by nature, so Fred won’t just leave his computer validating Bitcoin transactions 24/7 and running up his power bill just to help the network out for fun.

He needs a reward.

This is where the mining side of it comes in.

While the Bitcoin software is running, there is also a reward protocol running in the background.

This is a very complicated mathematical puzzle that your computer tries to solve, a bit like a lottery (I’ll explain it more below).

Whichever lucky miner solves the puzzle gets rewarded with some Bitcoin.

This incentivises people to maintain the Bitcoin network and contribute to securing the network, because they know they have a chance of “winning” some Bitcoin.

Why is this important?

It provides value to Bitcoin because it means Bitcoin can’t just be printed out of thin air. It requires computer equipment, electricity, and computing power to create a Bitcoin.

This is known in crypto terminology as proof-of-work.

Each block contains proof that resources were expended to create that block, i.e. proof of the work that block required.

You might have heard people complaining about how much power Bitcoin consumes, however, those people don’t realise this is a feature of Bitcoin, not a bug.

Mining Bitcoin is intentionally designed to be power intensive, because it means to create another blockchain like Bitcoin’s, you can’t just push a button on a computer.

You would need to expend 13 years (and counting) of computing power. And by the time you get there, Bitcoin will still be 13 years ahead of you. Because nobody can go back in time, cloning a blockchain as robust as Bitcoin’s is therefore impossible.

More importantly, to hack Bitcoin, you would need literally billions of dollars in computer power to take over the network, to produce the proof-of-work needed to take over the next block.

The large amount of resources needed to mine blocks is exactly what makes Bitcoin so resilient.

The second way mining provides value is it makes the supply of Bitcoin perfectly predictable.

Every hour, there is a specific amount of Bitcoin created and rewarded to miners. It is not possible to create more or less. The supply is fixed and hardwired into the code, and can never be changed.

This is in contrast to a fiat currency like the NZD – the government can print any amount they want, at any time. And the supply is not fixed – it is limitless.

So a decentralised currency, that requires energy to create, with a fixed supply that cannot be manipulated or inflated.

This summarises the first part of the trust equation.

The second part of this equation is the genius piece of technology we’ve been talking about – the blockchain.

HOW THE BLOCKCHAIN WORKS

A blockchain is a database. Its function is to store data.

The Bitcoin blockchain stores data such as how much Bitcoin is in each people’s wallet, and what transactions have been sent.

The difference between a blockchain and a regular database is, instead of being stored on just one computer, it is stored on thousands, maybe millions of computers around the world.

Let’s go back to Fred’s account with Kiwibank.

If Kiwibank wants to charge Fred a fee, they simply charge him.

He can cry about it if he wants, but he can’t really do anything.

Kiwibank says we’re charging you $10 in bank fees, and they charge it.

The only people who have access to Kiwibank’s database is Kiwibank themselves. Therefore they can do whatever they like, whenever they want.

How many times have you seen charges on your bank statement you didn’t approve or know about? And then you have to call the bank and ask them to reverse them?

This is a centralised system, where full control is given to a single entity.

Bitcoin works differently. Because it runs on a blockchain, its database is stored on many thousands of computers worldwide, such as Fred’s.

If anything is to change in that database, it needs to be updated on all those databases at the same time. This is known as consensus.

No one entity has the ability to charge you a fee or remove funds from your account.

For that to happen, everyone running the database needs to agree that this is the correct action, and update their records simultaneously.

If people can clearly see something not right is being done, such as Fred trying to send money he doesn’t have, they’ll reject it.

Similarly, if someone like Fred tries to tweak the database on his computer and give himself a million Bitcoin, it will be noticed quickly. If 1,000 computers are running the Bitcoin software, the other 999 will very easily see he is being malicious and reject it from the consensus.

Fred’s database might say he has a million Bitcoin, but not anyone else’s.

For Fred to rejoin the network, he will need to edit his database to be in line with all the others before he’s allowed to reconnect.

As you might have guessed, this is also what makes the Bitcoin blockchain immune to censorship.

If the US government tries to shut Bitcoin down, and disconnects all the nodes in America, there are still thousands of computers maintaining the network in 197 other countries. There may be a node in the jungle somewhere in Brazil, on a yacht in the Indian Sea, maybe a few in the Nepalese mountains. As long as one of these nodes is online at any one time, the network stays alive.

This is how decentralisation creates trust.

Now that you understand that a blockchain is simply a database, we can move on to how this database works, and why people believe it is so revolutionary.

You will need to understand the following four concepts:

  • First you will need to understand hashing.
  • Then you’ll be able to understand the mining algorithm.
  • Once you understand the mining algorithm, you can understand how blocks are formed.
  • And once you understand blocks you’ll be able to understand how they connect into a blockchain.

I will explain them below one by one.

We will get nerdy from here, so keep your brains on.

HASHING

To understand Bitcoin, you need to understand hashing.

Hashing is a form of encryption.

Encryption works like this – you give me a value, such as the word WINTER, and I give you an encrypted value, such as W#.

You will then know that anytime I write W#, I mean winter.

“Man, it’s really cold this W#”

Anybody that sees that will think, what the hell is he talking about?

But you – since you know the encryption – will understand what I mean.

So in this situation, we could say we are hashing the word WINTER.

And the hash is W#.

That’s not really the best example, but hopefully you get it.

It would help to see this in action so you have a mental image of what is actually happening.

Bitcoin uses a hashing algorithm known as SHA-256.

You can see an example of it using this generator.

Take a look:

I entered the input “moneybren.com” and here’s what it gave me:

So now we know, the hash of moneybren.com, using a SHA-256 hashing algorithm, is:

49177b7032545ce50469e4b03199f8a9af48169a8c6f4235558db76827c38c4f

You can try this yourself.

Just enter anything, like your name, and it will give you a unique hash that corresponds to whatever you entered.

Now, here’s a very important thing to understand about the SHA-256 algorithm:

No matter how long or short your input is, the algorithm will always produce an output that is 64 characters (256-bit).

Meaning if your input is 1 word, the hash is 64 characters, if your input is a million words, the hash is still 64 characters.

As an example, I pasted this entire article into the generator (5,000ish words) and the output was this:

Still 64 characters.

Meaning no matter how much data you want to store, you can do it in 64 characters with the SHA256 hash algorithm.

Instead of you (or a computer program) remembering thousands of lines of data, you can just remember the hash.

Pretty cool eh?

But not all hashing is created equal.

Some are better than others.

For a hashing algorithm to work for Bitcoin, it needs something known as pre-image resistance.

PRE-IMAGE RESISTANCE

Pre-image resistance means it is infeasible for you to find the hash input just by knowing the hash output.

Let me explain:

Using the SHA-256 generator, I am going to hash the word “one”.

The hash of “one” comes out as:

7692c3ad3540bb803c020b3aee66cd8887123234ea0c6e7143c0add73ff431ed

Question: If I showed you this string of characters above, would you be able to figure out, just by looking at it, that the hash input was “one”?

Of course not.

But let’s take another scenario.

Let’s say I give you a clue.

Let’s say I tell you the string of characters is the hash of a number between one and ten.

Now can you figure out what I hashed?

Of course you can.

All you need to do is go to the hashing calculator and enter every number between one and ten and see which one matches.

In less than a minute, you will have figured out that the string is the hash of “one”.

This is known as the brute force method.

Even though I can’t crack the algorithm itself, I can simply try every possibility until I find a match.

In this scenario, the brute force method was very effective. Since we know there were only ten possibilities, even a kid could have cracked the puzzle in a matter of minutes.

This means the pre-image resistance is poor.

However, let’s say we try to improve it. All we need to do is change the range of inputs.

Instead of telling you it’s a number between one and ten, let’s say I tell you it’s between one and five billion.

Can you still crack the input via brute force?

No (at least not in one lifetime).

This means the pre-image resistance is strong.

Why is this important?

It’s a key factor in the process of Bitcoin mining.

BITCOIN MINING

Now you should understand the following terms:

  • Hashing – Encrypting a string of characters.
  • Pre-image resistance – unable to decrypt something just by looking at it.
  • Brute force method – Decrypting something just by trying all the possibilities.

If you understand all of that, you can now understand Bitcoin mining.

All miners on the Bitcoin blockchain compete to solve a very complicated puzzle.

The miner who solves the puzzle “wins” the block and gets rewarded with some Bitcoin.

Then the next block arrives, and they do it all over again.

That’s the simple explanation.

For those of you who are interested in the complicated explanation (all of you, obviously, because this is so cool) here’s the long version:

Step 1: The Nonce

Bitcoin mining is all about finding a number known as the nonce.

Miners all compete to find the nonce.

First to find the nonce, gets the Bitcoin.

Simple.

If you think of Bitcoin mining as trying to open up a treasure chest full of Bitcoins, the nonce (short for “number only used once”) is the key to the chest.

Let me explain further (pay attention here because it gets nerdy):

With Bitcoin, approximately every ten minutes a new batch of transactions is formed and delivered to miners.

This batch of transactions is known as a block.

When it arrives, the first thing miners do is hash the entire contents of the block (you know what hashing means!)

So they chuck that entire block of transactions (remember, you can hash as much data as you want into a 64-character string) into the hashing calculator.

Then, miners add a number to the end of the hash (this number is the nonce).

It’s just a random number the miner has guessed.

Then the whole string (the block hash + the nonce) is hashed again.

If this final hash falls within the target range, the miner has solved the puzzle and they get rewarded with Bitcoin. 

It’s simply a race to find the correct nonce (also known as the golden nonce), using the brute force method.

Find the golden nonce, win the Bitcoin.

Confused? Me too. Here’s an example:

Let’s do it in a very simplified example.

Let’s say the target range on the Bitcoin software puzzle is to find a number less than 100.

And let’s say they’ve told us the nonce is between 5 and 10.

So here’s what happens:

The block comes in.

We hash it.

The hash of the block comes out as abcdef.

The next step is to brute force the puzzle – we simply try adding as many possible nonces to the hash.

Since we know the nonce is between 5 and 10, the first option we try will be abcdef5 (abcdef is the hash, 5 is the nonce).

Then we hash it again.

Let’s say the hash of abcdef5 comes out as 150.

Because 150 is not less than 100, we know that 5 is not the nonce.

So, we try again with abcdef6, abcdef7 and so on, until we find the correct nonce.

Of course with Bitcoin, it is not that simple. There are not only 5 possible nonces. There are millions.

Therefore Bitcoin miners need to operate on brute force, going through millions of nonces, racing to find the correct one (this is why Bitcoin mining requires so much computer power).

When a miner finds the correct nonce they notify the rest of the network.

The rest of the miners validate the nonce to ensure it is actually correct.

Then the winning miner receives a Bitcoin reward.

Then all miners receive the next block and the process repeats.

THE CONCEPT OF BLOCKS

Every second, people are sending transactions to the Bitcoin network.

For example, if I want to send 1 Bitcoin to Fred, I open my Bitcoin wallet and submit that transaction to the network.

Every ten minutes, miners then receive these transactions in a bundle of data. As we know, this bundle of information is known as a block.

But blocks are more than just transactions. A block also contains:

  1. Timestamp
  2. Difficulty target
  3. Nonce
  4. Hash of the previous block

It’s that last item that is essential to understanding blockchains in action. Let me explain:

Each block contains lots of data (like, a lot).

This data can’t be stored easily in blocks, because it’s just too big.

So how is it possible to keep a record of all the transactions in Bitcoin’s history?

You should already know the answer.

Hashing.

Let’s say we’ve just received the first block.

We will call it Block A.

With Block A, the transactions all get verified by miners, one of the miners finds the nonce, the block gets processed within the ten-minute window, everything is perfect, boom, Block A is confirmed.

Then miners move onto Block B.

Now with Block B, everything happens exactly the same.

Miners verify the transactions, nonce gets found, block is confirmed.

However, when the Bitcoin software adds Block B to the chain, it includes one very special thing inside that block.

It includes the hash of Block A.

Remember, including the hash is easy.

It’s just a 64-character string.

So even if Block A is enormous, it can still be hashed into a small 64-character string.

This continues down the line, so the hash of Block B will be included in Block C, and the hash of Block C will be included in Block D and so on.

This means every block is connected in a chain, hence the term blockchain.

Now think about this.

If someone tried to “hack” the Bitcoin blockchain and modify Block A to give himself a million Bitcoins, then the hash of Block A would change.

And that would mean it would no longer match the hash of Block A that’s recorded in Block B.

Therefore for this hack to be successful, they would also need to hack Block B and change that too.

However, after hacking Block B, the hash of Block B would change also, and it wouldn’t match the hash that’s been recorded in Block C.

So they would also need to hack Block C, and Block D, and so on.

In this example, it might not seem that impossible to pull this off, because there are only four blocks.

But what if there are 10 million blocks? And a new block being formed every 10 minutes?

Therefore, the blockchain cannot be modified because modifying one block requires modifying every other block as well.

Because all those blocks have already been confirmed, this task is very close to impossible (and it gets more impossible every ten minutes as a new block is added).

When people say the blockchain is secure and cannot be hacked, this is what they are talking about.

Successfully hacking the Bitcoin blockchain would require so much computer power to hack every single block simultaneously, it might be theoretically possible, but in reality, it’s not.

Not to mention, if someone were to spend billions in computer power to hack Bitcoin, it would be pointless – after Bitcoin got hacked, that chain would become worthless.

What rational person would spend billions on computer power to gain control of a worthless asset?

They would be better off just using all that computer power to mine Bitcoin.

This is what people mean when they say Bitcoin is self-reinforcing.

It is perfectly aligned with human nature to ensure people only act in the interests of its survival.

CONCLUSION

What did we learn?

That the Bitcoin network is secured by miners.

Mining is the process of verifying transactions, hashing them so they can be stored, and finding a secret key known as the nonce to earn a reward.

Each ten-minute block of transactions is known as a block.

Blocks are validated by miners during the mining process and then are added to a public database known as the blockchain.

The blockchain is immutable because every block is linked, therefore to corrupt one block, you need to corrupt every block ever created.

Do you now understand how Bitcoin works? What did I miss? Let me know in the comments.

Build Your First Million!

My free net worth tracker that I use daily is available to you, for free.

I've helped hundreds of Kiwis track their net worth, and grow it!

Just enter your email below and I'll send it right over.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}