But how does bitcoin actually work?

3Blue1Brown
7 Jul 201725:15

Summary

TLDRThis script delves into the intricacies of Bitcoin and cryptocurrencies, explaining their nature as decentralized digital currencies. It guides through the evolution from a communal ledger to a complex system of trustless verification, underpinned by cryptography. The concept of digital signatures, public and private keys, and the importance of a distributed ledger are discussed. The script also touches on the Bitcoin protocol's proof of work, block rewards, and the blockchain's consensus mechanism, highlighting the security and trust inherent in the system despite its lack of a central authority.

Takeaways

  • πŸ€” Bitcoin is a digital currency that operates without a central authority, such as a government or bank.
  • πŸ“ A communal ledger is used to track transactions among a group, which is a simplified version of a cryptocurrency's blockchain.
  • πŸ” Digital signatures are used to ensure the authenticity of transactions, providing a level of trust in the system.
  • πŸ”‘ Public and private key pairs are fundamental to digital signatures, allowing for secure and verifiable transactions.
  • πŸ’‘ The concept of 'proof of work' is central to Bitcoin, where computational effort is used to validate transactions and create new blocks.
  • πŸ”— Blocks in the blockchain are linked through cryptographic hash functions, ensuring the integrity and order of transactions.
  • πŸ’° Miners are rewarded with block rewards and transaction fees for their efforts in maintaining the blockchain.
  • πŸš€ The Bitcoin protocol adjusts the difficulty of finding a valid block to maintain an average block time of about 10 minutes.
  • πŸ“‰ Bitcoin's supply is capped at 21 million, with the block reward halving approximately every four years.
  • πŸ”„ Transaction fees incentivize miners to include transactions in blocks, affecting the speed and cost of Bitcoin transactions.
  • πŸ“š Understanding the fundamentals of Bitcoin and cryptocurrencies is important for anyone considering investing or using them.

Q & A

  • What is the fundamental concept of Bitcoin?

    -Bitcoin is a digital currency that operates on a decentralized ledger system called a blockchain, which records all transactions. It does not rely on any central authority like a government or a bank.

  • How does a communal ledger work in the context of the script?

    -A communal ledger is a public record that keeps track of all payments among a group of people. It's updated with transactions and settled periodically, with each participant responsible for adding lines to the ledger.

  • What role does cryptography play in the creation of a cryptocurrency like Bitcoin?

    -Cryptography is used to create digital signatures, ensuring that transactions are secure and can only be approved by the sender. It also helps in generating public and private key pairs, which are crucial for the security and verification of transactions.

  • What is a digital signature and how does it function?

    -A digital signature is a cryptographic tool that verifies the authenticity of a transaction. It is unique to each transaction and requires the sender's private key to create. It ensures that only the sender can approve a transaction, and it cannot be forged by others.

  • How does the concept of 'proof of work' contribute to the security of the Bitcoin network?

    -Proof of work is a mechanism where miners must solve a complex mathematical problem (find a special number) that makes the hash of a block start with a certain number of zeros. This requires significant computational effort, making it infeasible for attackers to create fraudulent transactions or alter the blockchain.

  • What is a blockchain and how does it ensure a consensus among participants?

    -A blockchain is a chain of blocks, each containing a list of transactions and a proof of work. It ensures a consensus by having all participants agree on the longest chain, which represents the most work done. This process prevents double-spending and maintains the integrity of the ledger.

  • How does the Bitcoin network handle the creation of new blocks and the reward for miners?

    -New blocks are created by miners who solve the proof of work. As a reward for their efforts, miners receive a block reward, which is a certain amount of Bitcoin. This process also introduces new Bitcoin into the economy.

  • What is the purpose of transaction fees in the Bitcoin network?

    -Transaction fees are optional payments that users can include with their transactions. They serve as an incentive for miners to prioritize and include those transactions in the next block, especially when the block has limited space for transactions.

  • How does the Bitcoin protocol ensure that the total supply of Bitcoin is limited?

    -The Bitcoin protocol caps the total supply at 21 million coins. This is achieved by halving the block reward approximately every four years (every 210,000 blocks), an event known as 'halving.'

  • What is the significance of the 10-minute block time in the Bitcoin network?

    -The 10-minute block time is an average target for how long it should take to find a new block. This time frame is adjusted dynamically to maintain the target, ensuring a consistent rate of new block discovery and preventing the network from becoming too easy or too difficult to mine.

  • How does the Bitcoin network prevent double-spending?

    -Double-spending is prevented by requiring each transaction to include a unique ID and by maintaining a full history of transactions. This ensures that once a transaction is recorded and confirmed, the same amount cannot be spent again by the sender.

Outlines

00:00

πŸ€” Understanding Bitcoin: A Digital Currency

This paragraph introduces the concept of Bitcoin as a digital currency without a central authority, explaining its decentralized nature and the lack of a single point of control. It sets the stage for a detailed exploration of how Bitcoin might have been invented, starting with a communal ledger for tracking payments among friends and gradually introducing cryptographic concepts to eliminate the need for trust.

05:01

πŸ” Digital Signatures and Trust

The second paragraph delves into the role of digital signatures in ensuring trust in a public ledger system. It explains how public and private key pairs work to create unique signatures for each transaction, making it infeasible for others to forge signatures. The paragraph also addresses the issue of duplicate transactions and introduces the concept of unique transaction IDs to prevent fraud.

10:02

πŸ“‹ The Evolution to Cryptocurrency

This paragraph discusses the transition from a simple ledger system to a cryptocurrency, highlighting the removal of physical currency and the creation of 'ledger dollars' (LD). It emphasizes the importance of the transaction history as the currency itself and introduces the idea of a distributed ledger, where each participant maintains their own copy, eliminating the need for a central host.

15:03

πŸ’‘ Proof of Work and Blockchain

The fourth paragraph explains the core concept of Bitcoin's blockchain technology, focusing on the proof of work mechanism. It describes how a cryptographic hash function is used to create a unique 'proof' for each block of transactions, ensuring that the blockchain is secure and resistant to fraudulent activities. The paragraph also introduces the idea of block rewards and mining, which incentivizes participants to contribute to the network.

20:04

πŸš€ Bitcoin Mining and Network Security

The final paragraph discusses the practical aspects of Bitcoin mining, including the process of finding a special number to validate a block and the reward system for miners. It explains how the network maintains security by favoring the longest blockchain and how transaction fees incentivize miners to include transactions in blocks. The paragraph concludes by acknowledging the limitations of Bitcoin's transaction processing and the potential for future developments in cryptocurrency technology.

Mindmap

Keywords

πŸ’‘Bitcoin

Bitcoin is a digital currency that operates without a central authority or government. It is the first and most well-known cryptocurrency, created in 2009. In the video, Bitcoin is used as an example to explain the concept of cryptocurrencies and their underlying technology, such as the blockchain and decentralized ledger system.

πŸ’‘Cryptocurrency

A cryptocurrency is a type of digital or virtual currency that uses cryptography for security and operates on a decentralized system, typically a blockchain. The video explains that cryptocurrencies like Bitcoin are designed to remove the need for trust in financial transactions by using cryptographic techniques to verify and record transactions.

πŸ’‘Decentralized Ledger

A decentralized ledger is a database that is distributed across multiple sites, computers, or nodes, and is maintained by a network of participants who validate and record transactions. In the context of the video, this concept is central to understanding how Bitcoin and other cryptocurrencies function, as they rely on a public ledger that is not controlled by any single entity.

πŸ’‘Blockchain

Blockchain is a chain of blocks, each containing a list of transactions, that are linked and secured using cryptography. This term is used in the video to describe the structure of the Bitcoin network, where each block contains a proof of work and the hash of the previous block, creating a chain that is difficult to alter or tamper with.

πŸ’‘Proof of Work

Proof of work is a consensus mechanism used in cryptocurrency networks to secure transactions and prevent double-spending. It requires participants to perform a certain amount of computational work, such as solving a complex mathematical problem, to add a new block to the blockchain. In the video, proof of work is explained as a way to ensure that the most computationally effortful blockchain is considered the valid one.

πŸ’‘Digital Signatures

Digital signatures are cryptographic tools that provide a way to verify the authenticity and integrity of a message or transaction. They are used in the video to illustrate how transactions in a cryptocurrency network can be securely signed by the sender, ensuring that only the sender can create a valid signature for a given transaction.

πŸ’‘Public Key-Private Key Pair

A public key-private key pair is a set of cryptographic keys used in asymmetric cryptography. The public key is shared with others to allow them to verify signatures or encrypt messages, while the private key is kept secret and used to sign transactions or decrypt messages. In the video, this concept is crucial for explaining how digital signatures work in the context of cryptocurrency transactions.

πŸ’‘Hash Function

A hash function is a mathematical algorithm that takes an input (or 'message') and returns a fixed-length string of characters, which is the 'hash' or 'digest' of the input. It is used in the video to explain how a cryptographic hash function can be used to create a unique representation of a block of transactions, which is then used in the proof of work mechanism.

πŸ’‘Block Reward

Block reward is the incentive given to miners for successfully adding a new block to the blockchain. In the Bitcoin network, this reward includes newly created bitcoins and sometimes transaction fees. The video explains that block rewards are a key component of the Bitcoin protocol, as they incentivize miners to contribute their computing power to the network.

πŸ’‘Transaction Fees

Transaction fees are optional payments included in a cryptocurrency transaction to incentivize miners to include that transaction in the next block they mine. The video mentions that while the block reward is a primary source of income for miners, transaction fees provide an additional incentive, especially when the block reward decreases over time.

πŸ’‘Halving

Halving, also known as a 'halvening,' is an event in the Bitcoin protocol where the block reward is cut in half. This happens approximately every four years or after every 210,000 blocks are mined. The video explains that halving is a mechanism to control the supply of Bitcoin, ensuring that there will never be more than 21 million Bitcoins in existence.

Highlights

Bitcoin is a fully digital currency without a central authority.

Bitcoin transactions are managed by a decentralized network, not banks.

The creator of Bitcoin remains anonymous.

Cryptocurrency is a digital currency protected by cryptography.

Bitcoin is the first implemented example of a cryptocurrency.

Cryptocurrencies are traded on exchanges alongside traditional currencies.

Understanding Bitcoin involves grasping the technical details of its operation.

Digital signatures are used to verify the authenticity of transactions.

Public and private key pairs are fundamental to digital signatures.

The Bitcoin protocol uses a proof of work system to validate transactions.

A blockchain is a chain of blocks, each containing a list of transactions.

Miners create new blocks and are rewarded with block rewards and transaction fees.

The Bitcoin network adjusts the difficulty of finding a new block to maintain a 10-minute average block time.

The total supply of Bitcoin is capped at 21 million.

Transaction fees incentivize miners to include transactions in blocks.

The Bitcoin network's security relies on the computational effort required for fraudulent activities.

To achieve consensus, the longest blockchain is considered the valid one.

The Bitcoin protocol ensures that once a transaction is confirmed, it cannot be reversed.

The process of creating new blocks is often referred to as mining.

Bitcoin's transaction throughput is limited, leading to higher transaction fees.

Transcripts

play00:03

What does it mean to have a Bitcoin?

play00:07

Many people have heard of Bitcoin, that it's a fully digital currency

play00:11

with no government to issue it, that no banks need to manage accounts

play00:15

and verify transactions, and that no one really knows who invented it.

play00:19

And yet many people don't know the answer to this question, at least not in full.

play00:24

To get there, and to make sure that the technical details underlying

play00:27

the answer actually feel motivated, we're going to walk through,

play00:31

step by step, how you might have invented your own version of Bitcoin.

play00:36

We'll start with you keeping track of payments with your friends using a communal ledger,

play00:40

and then as you start to trust your friends and the world around you less and less,

play00:44

and if you're clever enough to bring in a few ideas from cryptography to help circumvent

play00:49

the need for trust, what you end up with is what's called a cryptocurrency.

play00:53

Bitcoin is just the first implemented example of a cryptocurrency,

play00:57

and now there are thousands more on exchanges with traditional currencies.

play01:03

Walking the path of inventing your own can help to set the foundations

play01:06

for understanding some of the more recent players in the game,

play01:09

and recognizing when and why there's room for different design choices.

play01:14

In fact, one of the reasons I chose this topic is that in the last year there's

play01:18

been a huge amount of attention, investment, and hype directed at these currencies.

play01:24

I'm not going to comment or speculate on the current or future exchange rates,

play01:28

but I think we'd all agree that anyone looking to buy a cryptocurrency should really know

play01:33

what it is.

play01:33

And I don't just mean in terms of analogies with vague connections to gold mining,

play01:38

I mean an actual direct description of what the computers are doing when we send,

play01:43

receive, and create cryptocurrencies.

play01:46

One thing worth stressing is that even though you and I are going to dig into

play01:50

the details here, and that takes meaningful time,

play01:52

you don't actually need to know those details if you just want to use the cryptocurrency,

play01:57

just like you don't need to know the details of what happens under the hood when

play02:01

you swipe a credit card.

play02:03

Like any digital payment, there's lots of user-friendly applications that let

play02:07

you just send and receive the currencies without thinking about what's going on.

play02:11

The difference is that the backbone underlying this is not a bank that

play02:15

verifies transactions, instead it's a clever system of decentralized

play02:20

trustless verification based on some of the math born in cryptography.

play02:25

But to start I want you to actually set aside the thought

play02:28

of cryptocurrencies and all that just for a few minutes.

play02:31

We're going to begin the story with something more down to earth,

play02:34

ledgers and digital signatures.

play02:36

If you and your friends exchange money pretty frequently,

play02:39

paying your share of the dinner bill and such,

play02:41

it can be inconvenient to exchange cash all the time.

play02:44

So you might keep a communal ledger that records all the

play02:47

payments you intend to make at some point in the future.

play02:50

Alice pays Bob $20, Bob pays Charlie $40, things like that.

play02:55

This ledger is going to be something public and accessible to everyone,

play02:59

like a website where anyone can go and add new lines.

play03:02

And let's say at the end of every month you all get together,

play03:05

look at the list of transactions, and settle up.

play03:08

If you spent more than you received, you put that money in the pot,

play03:11

and if you received more than you spent, you take that money out.

play03:15

So the protocol for being part of this very simple system might look like this.

play03:20

Anyone can add lines to the ledger, and at the end

play03:22

of every month you all get together and settle up.

play03:26

Now one problem with a public ledger like this is that anyone can add a line.

play03:31

So what's to prevent Bob from going and writing

play03:34

Alice pays Bob $100 without Alice approving?

play03:37

How are we supposed to trust that all of these

play03:40

transactions are what the sender meant them to be?

play03:44

Well this is where the first bit of cryptography comes in, digital signatures.

play03:49

Like handwritten signatures, the idea here is that Alice should be able to add

play03:53

something next to that transaction that proves that she has seen it and that she's

play03:58

approved of it, and it should be infeasible for anyone else to forge that signature.

play04:04

At first, it might seem like a digital signature shouldn't even be possible.

play04:09

I mean, whatever data makes up that signature can just be read and copied by a computer.

play04:14

So how do you prevent forgeries?

play04:17

Well the way this works is that everyone generates what's called a

play04:20

public key-private key pair, each of which looks like some string of bits.

play04:24

The private key is sometimes also called a secret key,

play04:27

so we can abbreviate it as SK while abbreviating the public key as PK.

play04:32

As the name suggests, this secret key is something you want to keep to yourself.

play04:37

In the real world, your handwritten signature looks

play04:39

the same no matter what document you're signing.

play04:42

But a digital signature is actually much stronger,

play04:44

because it changes for different messages.

play04:47

It looks like some string of 1s and 0s, commonly something like 256 bits,

play04:52

and altering the message even slightly completely changes what

play04:56

the signature on that message should look like.

play05:00

Speaking a little more formally, producing a signature involves a

play05:04

function that depends both on the message itself and on your private key.

play05:09

The private key ensures that only you can produce that signature,

play05:12

and the fact that it depends on the message means that no one can

play05:16

just copy one of your signatures and forge it on another message.

play05:21

Hand-in-hand with this is a second function used to verify that a signature is valid,

play05:25

and this is where the public key comes into play.

play05:29

All it does is output true or false to indicate if this was a signature produced

play05:33

by the private key associated with the public key you're using for verification.

play05:38

I won't go into the details of how exactly both these functions work,

play05:42

but the idea is that it should be completely infeasible to

play05:46

find a valid signature if you don't know the secret key.

play05:50

Specifically, there's no strategy better than just guessing and checking

play05:53

random signatures, which you can check using the public key that everyone knows.

play05:58

Now think about how many signatures there are with a length of 256 bits.

play06:03

That's 2 to the power of 256!

play06:07

This is a stupidly large number.

play06:09

To call it astronomically large would be giving way too much credit to astronomy.

play06:14

In fact, I made a supplemental video devoted just

play06:17

to illustrating what a huge number this is.

play06:20

Right here, let's just say that when you verify that a signature against a given message

play06:25

is valid, you can feel extremely confident that the only way someone could have produced

play06:30

it is if they knew the secret key associated with the public key you used for

play06:34

verification.

play06:37

Making sure people sign transactions on the ledger is pretty good,

play06:40

but there's one slight loophole.

play06:42

If Alice signs a transaction like Alice pays Bob $100,

play06:46

even though Bob can't forge Alice's signature on a new message,

play06:50

he could just copy that same line as many times as he wants.

play06:54

That message-signature combination remains valid.

play06:57

To get around this, we make it so that when you sign a transaction,

play07:02

the message has to include some sort of unique ID associated with that transaction.

play07:07

That way, if Alice pays Bob $100 multiple times,

play07:10

each one of those lines on the ledger requires a completely new signature.

play07:16

Great, digital signatures remove a huge aspect of trust in this initial protocol.

play07:22

But even still, if you were to really do this,

play07:24

you would be relying on an honor system of sorts.

play07:27

Namely, you're trusting that everyone will actually follow

play07:30

through and settle up in cash at the end of each month.

play07:33

What if, for example, Charlie racks up thousands

play07:36

of dollars in debt and just refuses to show up?

play07:40

The only real reason to revert back to cash to

play07:43

settle up is if some people owe a lot of money.

play07:47

So maybe you have the clever idea that you never actually have to settle up in cash as

play07:52

long as you have some way to prevent people from spending too much more than they take in.

play07:57

Maybe you start by having everyone pay $100 into the pot,

play08:01

and then have the first few lines of the ledger read Alice gets $100, Bob gets $100,

play08:06

Charlie gets $100, etc.

play08:09

Now, just don't accept any transactions where someone

play08:12

is spending more than they already have on that ledger.

play08:16

For example, if the first two transactions are Charlie pays Alice

play08:21

$50 and Charlie pays Bob $50, if he were to try to add Charlie pays you $20,

play08:27

that would be invalid, as invalid as if he had never signed it.

play08:32

Notice, this means verifying a transaction requires

play08:36

knowing the full history of transactions up to that point.

play08:40

This is also going to be true in cryptocurrencies,

play08:43

though there is a little room for optimization.

play08:48

What's interesting here is that this step removes the

play08:51

connection between the ledger and actual physical US dollars.

play08:56

In theory, if everyone in the world was using this ledger,

play08:59

you could live your whole life just sending and receiving money

play09:03

on this ledger without ever having to convert to real US dollars.

play09:07

In fact, to emphasize this point, let's start referring to

play09:10

the quantities on the ledger as ledger dollars, or LD for short.

play09:14

You are of course free to exchange ledger dollars for real US dollars.

play09:19

For example, maybe Alice gives Bob a $10 bill in the real world in exchange for him

play09:24

adding and signing the transaction $10 Bob pays Alice $10 to this communal ledger.

play09:30

But exchanges like that are not guaranteed by the protocol.

play09:34

It's now more analogous to how you might exchange

play09:37

dollars for Euros or any other currency on the open market.

play09:41

It's just its own independent thing.

play09:44

This is the first important thing to understand about Bitcoin,

play09:48

or any other cryptocurrency.

play09:49

What it is, is a ledger.

play09:53

The history of transactions is the currency.

play09:57

Of course, with Bitcoin, money doesn't enter the ledger with people buying in using cash.

play10:02

I'll get to how new money enters the ledger in just a few minutes.

play10:05

But before that, there's actually an even more significant difference

play10:08

between our current system of ledger dollars and how cryptocurrencies work.

play10:13

So far, I've said that this ledger is in some public place,

play10:16

like a website where anyone can add new lines.

play10:19

But that would require trusting a central location, namely,

play10:22

who hosts the website, who controls the rules of adding new lines.

play10:27

To remove that bit of trust, we'll have everybody keep their own copy of the ledger.

play10:32

Then when you want to make a transaction, like Alice pays Bob 100 Ledger Dollars,

play10:37

you do broadcast that out into the world for people to hear

play10:41

and record on their own private ledgers.

play10:44

But unless you do something more, this system is absurdly bad.

play10:49

How could you get everyone to agree on what the right ledger is?

play10:53

When Bob receives a transaction, like Alice pays Bob 10 Ledger Dollars,

play10:57

how can he be sure that everyone else received and believes that same transaction?

play11:02

That he'll be able to later on go to Charlie and use

play11:04

those same 10 Ledger Dollars to make a transaction?

play11:08

Really, imagine yourself just listening to transactions being broadcast.

play11:12

How can you be sure that everyone else is recording

play11:15

the same transactions and in the same order?

play11:19

This is really the heart of the issue.

play11:21

This is an interesting puzzle.

play11:23

Can you come up with a protocol for how to accept or reject transactions,

play11:27

and in what order, so that you can feel confident that anyone else in the world

play11:32

who's following that same protocol has a personal ledger that looks the same as yours?

play11:38

This is the problem addressed in the original Bitcoin paper.

play11:44

At a high level, the solution that Bitcoin offers is to trust

play11:48

whichever ledger has the most computational work put into it.

play11:52

I'll take a moment to explain exactly what that means.

play11:55

It involves a cryptographic hash function.

play11:58

The general idea that we'll build to is that if you use computational work as

play12:03

a basis for what to trust, you can make it so that fraudulent transactions and

play12:07

conflicting ledgers require an infeasible amount of computation to bring about.

play12:13

Again, I'll remind you that this is getting well into the weeds

play12:16

beyond what anyone would need to know just to use a currency like this.

play12:20

But it's a really cool idea, and if you understand it,

play12:22

you understand the heart of Bitcoin and other cryptocurrencies.

play12:28

So first things first, what's a hash function?

play12:30

The inputs for one of these functions can be any kind of message or file,

play12:34

it really doesn't matter. And the output is a string of bits

play12:38

with some kind of fixed length, like 256 bits.

play12:41

This output is called the hash or digest of the message,

play12:45

and the intent is that it looks random.

play12:48

It's not random, it always gives the same output for a given input.

play12:52

But the idea is that if you slightly change the input,

play12:55

maybe editing just one of the characters, the resulting hash changes completely.

play13:00

In fact, for the hash function I'm showing here, called SHA256,

play13:05

the way the output changes as you slightly change that input is entirely unpredictable.

play13:12

You see, this is not just any hash function, it's a cryptographic hash function.

play13:17

That means it's infeasible to compute in the reverse direction.

play13:21

If I show you some string of 1s and 0s, and ask you to find an

play13:25

input so that the SHA256 hash of that input gives this exact string of bits,

play13:30

you will have no better method than to just guess and check.

play13:35

And again, if you want to feel for how much computation would be needed to

play13:39

go through two to the 256 guesses, just take a look at the supplement video.

play13:44

I actually had way too much fun writing that thing.

play13:48

You might think that if you just really dig into the details of how exactly this function

play13:53

works, you could reverse engineer the appropriate input without having to guess and check.

play13:58

But no one has ever figured out a way to do that.

play14:01

Interestingly, there's no cold hard rigorous proof

play14:04

that it's hard to compute in the reverse direction.

play14:07

And yet, a huge amount of modern security depends on cryptographic

play14:11

hash functions and the idea that they have this property.

play14:14

If you were to look at what algorithms underlie the secure connection

play14:18

that your browser is making with YouTube right now,

play14:21

or that it makes with your bank, you'll likely see the name SHA256 show up in there.

play14:27

For right now, our focus will be on how such a function can prove that a particular

play14:32

list of transactions is associated with a large amount of computational effort.

play14:38

Imagine someone shows you a list of transactions, and they say, hey,

play14:42

I found a special number so that when you put that number at the end of this list of

play14:47

transactions, and apply SHA256 to the entire thing,

play14:50

the first 30 bits of that output are all zeros.

play14:54

How hard do you think it was for them to find that number?

play14:58

Well, for a random message, the probability that a hash happens to start

play15:02

with 30 successive zeros is 1 in 2 to the 30, which is about 1 in a billion.

play15:08

And because SHA256 is a cryptographic hash function,

play15:11

the only way to find a special number like that is just guessing and checking.

play15:16

So this person almost certainly had to go through about a

play15:19

billion different numbers before finding this special one.

play15:23

And once you know that number, it's really quick to verify,

play15:26

you just run the hash and see that there are 30 zeros.

play15:29

So in other words, you can verify that they went through a large amount of work,

play15:33

but without having to go through that same effort yourself.

play15:37

This is called a proof of work.

play15:39

And importantly, all of this work is intrinsically tied to the list of transactions.

play15:44

If you change one of those transactions, even slightly,

play15:47

it would completely change the hash.

play15:50

So you'd have to go through another billion guesses to find a new proof of work,

play15:54

a new number that makes it so that the hash of the altered list

play15:57

together with this new number starts with 30 zeros.

play16:01

So now think back to our distributed ledger situation.

play16:04

Everyone is there broadcasting transactions and we want

play16:07

a way for them to agree on what the correct ledger is.

play16:12

As I mentioned, the idea behind the original Bitcoin paper is to

play16:15

have everyone trust whichever ledger has the most work put into it.

play16:19

The way this works is to first organize a given ledger into blocks,

play16:22

where each block consists of a list of transactions together with a proof of work.

play16:27

That is, a special number so that the hash of

play16:30

the whole block starts with a bunch of zeros.

play16:33

For the moment, let's say it has to start with 60 zeros,

play16:36

but later we'll return back to a more systematic way you might want to choose that number.

play16:40

In the same way that a transaction is only considered valid when it's signed

play16:45

by the sender,

play16:45

A block is only considered valid if it has a proof of work.

play16:50

Also, to make sure there's a standard order to these blocks,

play16:54

we'll make it so that a block has to contain the hash of the previous block at its header.

play17:00

That way, if you were to go back and change any one of the blocks,

play17:03

or to swap the order of two blocks, it would change the block that comes after it,

play17:08

which changes the block's hash, which changes the one that comes after it, and so on.

play17:13

That would require redoing all of the work, finding a new special number

play17:17

for each of these blocks that makes their hashes start with 60 zeros.

play17:22

Because blocks are chained together like this,

play17:24

instead of calling it a ledger, it's common to call it a blockchain.

play17:30

As part of our updated protocol, we'll now allow

play17:32

anyone in the world to be a block creator.

play17:35

What that means is that they're going to listen for transactions being broadcast,

play17:39

collect them into some block, and then do a whole bunch of work to find a

play17:42

special number that makes the hash of that block start with 60 zeros.

play17:46

Once they find it, they broadcast out the block they found.

play17:50

To reward a block creator for all this work, when she puts together a block,

play17:55

we'll allow her to include a very special transaction at the top of it,

play17:59

in which she gets, say, 10 ledger dollars out of thin air.

play18:03

This is called the block reward, and it's an exception to

play18:06

our usual rules about whether or not to accept transactions.

play18:10

It doesn't come from anyone, so it doesn't have to be signed.

play18:13

It also means that the total number of ledger

play18:16

dollars in our economy increases with each new block.

play18:20

Creating blocks is often called mining, since it requires doing a lot of work,

play18:25

and it introduces new bits of currency into the economy.

play18:29

But when you hear or read about miners, keep in mind that what they're

play18:33

really doing is listening for transactions, creating blocks,

play18:36

broadcasting those blocks, and getting rewarded with new money for doing so.

play18:41

From the miners' perspective, each block is like a miniature lottery,

play18:45

where everyone is guessing numbers as fast as they can,

play18:48

until one lucky individual finds a special number that makes the hash of the block

play18:53

start with many zeros, and they get the reward.

play18:57

For anyone else who just wants to use this system to make payments,

play19:01

instead of listening for transactions, they all start listening just for blocks

play19:05

being broadcast by miners, and updating their own personal copies of the blockchain.

play19:10

Now the key addition to our protocol is that if you hear two

play19:14

distinct blockchains with conflicting transaction histories,

play19:18

you defer to the longest one, the one with the most work put into it.

play19:22

If there's a tie, just wait until you hear an

play19:25

additional block that makes one of them longer.

play19:28

So even though there's no central authority, and everyone is maintaining their own

play19:33

copy of the blockchain, if everyone agrees to give preference to whichever blockchain

play19:38

has the most work put into it, we have a way to arrive at decentralized consensus.

play19:43

To see why this makes for a trustworthy system,

play19:45

and to understand at what point you should trust that a payment is legit,

play19:49

it's actually really helpful to walk through exactly what it would take to

play19:53

fool someone using this system.

play19:55

Maybe Alice is trying to fool Bob with a fraudulent block,

play19:58

namely she tries to send him one that includes her paying him 100 Ledger dollars,

play20:03

but without broadcasting that block to the rest of the network,

play20:07

that way everyone else still thinks she has those 100 Ledger dollars.

play20:11

To do this, she would have to find a valid proof of work before all the other miners,

play20:16

each working on their own block.

play20:19

And that could definitely happen, maybe Alice just

play20:21

happens to win this miniature lottery before everyone else.

play20:25

But Bob is still going to be hearing the broadcasts made by other miners,

play20:29

so to keep him believing this fraudulent block,

play20:32

Alice would have to do all the work herself to keep adding blocks on this

play20:36

special fork in Bob's blockchain that's different from what he's hearing

play20:40

from the rest of the miners.

play20:42

Remember, as per the protocol, Bob always trusts the longest chain he knows about.

play20:49

Alice might be able to keep this up for a few blocks if just by chance she

play20:53

finds blocks more quickly than the rest of the miners on the network all combined.

play20:58

But unless she has close to 50% of the computing resources among all of the miners,

play21:03

the probability becomes overwhelming that the blockchain that all the other miners

play21:08

are working on grows faster than the single fraudulent blockchain Alice is feeding to Bob.

play21:15

So after enough time, Bob will just reject what he's hearing from

play21:19

Alice in favor of the longer chain that everyone else is working on.

play21:23

Notice, that means you shouldn't necessarily trust a new block you hear immediately.

play21:29

Instead, you should wait for several new blocks to be added on top of it.

play21:33

If you still haven't heard of any longer blockchains,

play21:36

you can trust that this block is part of the same chain that everyone else is using.

play21:42

And with that, we've hit all the main ideas.

play21:45

This distributed ledger system based on a proof of work is more or less

play21:49

how the Bitcoin protocol works, and how many other cryptocurrencies work.

play21:54

There's just a few details to clear up.

play21:56

Earlier I said that the proof of work might be to find a

play21:59

special number so that the hash of the block starts with 60 zeros.

play22:03

Well, the way the actual Bitcoin protocol works is to periodically change that

play22:07

number of zeros so that it should take, on average, 10 minutes to find a new block.

play22:12

So as there are more and more miners added to the network,

play22:16

the challenge gets harder and harder in such a way that this

play22:19

miniature lottery only has about one winner every 10 minutes.

play22:23

Many newer cryptocurrencies have much shorter block times than that.

play22:28

And all of the money in Bitcoin ultimately comes from some block reward.

play22:32

In the beginning, these rewards were 50 Bitcoin per block.

play22:36

There's actually a great website you can go to called Block

play22:38

Explorer that makes it easy to look through the Bitcoin blockchain.

play22:41

And if you look at the very first few blocks on the chain,

play22:45

they contain no transactions other than that 50 Bitcoin reward to the miner.

play22:49

But every 210,000 blocks, which is about every 4 years, that reward gets cut in half.

play22:56

So right now, the reward is 12.5 Bitcoin per block.

play23:00

And because this reward decreases geometrically over time,

play23:04

it means there will never be more than 21 million Bitcoin in existence.

play23:10

However, this doesn't mean miners will stop earning money.

play23:13

In addition to the block reward, miners can also pick up transaction fees.

play23:18

The way this works is that whenever you make a payment,

play23:21

you can purely optionally include a transaction fee with it

play23:24

that will go to the miner of whichever block includes that payment.

play23:29

The reason you might do that is to incentivize miners to actually

play23:32

include the transaction you broadcast into the next block.

play23:36

You see, in Bitcoin, each block is limited to about 2400 transactions,

play23:41

which many critics argue is unnecessarily restrictive.

play23:45

For comparison, Visa processes an average of about 1700 transactions per second,

play23:51

and they're capable of handling more than 24,000 per second.

play23:56

This comparatively slow processing on Bitcoin makes for higher transaction fees,

play24:00

since that's what determines which transactions miners choose to include in a new block.

play24:07

All of this is far from a comprehensive coverage of cryptocurrencies.

play24:12

There are still many nuances and alternate design choices that I haven't even touched.

play24:16

But my hope is that this can provide a stable WaitButWhy-style tree-trunk of

play24:20

understanding for anyone looking to add a few more branches with further reading.

play24:25

Like I said at the start, one of the motives behind this is that a lot of money has

play24:28

started flowing towards cryptocurrencies, and even though I don't want to make any

play24:32

claims about whether that's a good or bad investment,

play24:35

I really do think it's healthy for people getting into the game to at least know the

play24:38

fundamentals of the technology.

play24:41

As always, my sincerest thanks to those of you making this channel possible on Patreon.

play24:46

I understand that not everyone is in a position to contribute,

play24:49

but if you're still interested in helping out,

play24:51

one of the best ways to do that is simply to share videos that you think

play24:54

might be interesting or helpful to others.

play24:57

I know you know that, but it really does help.

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
BitcoinCryptocurrencyBlockchainDecentralizationDigital CurrencyCryptographyProof of WorkEconomic SystemsInvestmentTechnology