What I would like to do is describe an imaginary,
or a fictitious, Bitcoin transaction.
And then talk about how somebody might try to game
or defraud the system.
And why that's not only mathematically hard to do,
but why there's actually an incentive-- actually
an economic incentive in the Bitcoin system
for different people to behave honestly.
So let's suppose that there is someone out there named Dan,
and that Dan wants to order a pizza-- maybe
a cheese pizza, from Pete's Pizza Shop.
And let's say that Pete's Pizza Shop accepts Bitcoins
as payment, and that it costs 1 Bitcoin for a pizza pie.
And imagine that Dan receive previously--
let's say he received 5 Bitcoins from his cousin, Carol.
So maybe Carol, who I'm going to label by C,
gave to Dan 5 Bitcoins, which we can label as a B
with a circle around it.
And that he wants to use 1 of these 5 Bitcoins
to buy a pizza from Pete.
And so what Dan's Bitcoin client will do
is it will create a transaction record that
includes information about how Dan got these Bitcoins.
In this case, it includes information
about this transaction between Carol, who we've marked by C,
and Dan for 5 Bitcoins.
And then it specifies that Dan wants
to give one of these Bitcoins to Pete--
and we'll label Pete by a P. And also
that Dan is going to take the remaining 4 Bitcoins.
And that will be basically change to himself.
And the way that Bitcoin is built
is that you have to actually specify the change,
because you need to have a way-- whatever goes into the Bitcoin
system has to come out at the other end.
And so you can't have a transaction
where the numbers don't add up.
And so whatever is remaining is either change, or part of it
can be used as a transaction fee.
And so on.
But for this example, to keep things simple,
I'll assume that there is no transaction fee in place.
The transaction fee is just 0.
And we'll focus only on the situation in which everything
is being accounted for in the transaction.
Now, this transaction record is going
to be broadcast out to the entire Bitcoin world.
And so in particular, Pete is going
to receive a copy of this transaction.
But in addition to Pete receiving it,
so too will the other people on the Bitcoin system.
And if you recall, there are these special nodes,
the special entities or people in Bitcoin,
that are known as Bitcoin miners.
And these Bitcoin miners are going
to be responsible for making sure that everything checks out
in the transaction from a global perspective.
What they do is they look at the full record of transactions.
And this transaction record is public.
It's known as a transaction block chain,
and I've put a description of the transaction block chain
right here.
And this transaction block chain contains the history
of every single transaction that's
ever occurred within the Bitcoin system
from the beginning of time-- the time of the first block,
which is known in Bitcoin as the genesis block.
And everyone can verify the details of any transaction
if they want to because that information is public.
And in particular, what these Bitcoin miners will look at
is they'll look at whether or not Dan previously
received five Bitcoins from anybody else.
In this particular case, it was his cousin, Carol.
Whether or not Dan has tried to spend those Bitcoin previously.
And so on and so forth.
And these Bitcoin miners are all collectively
trying to take all these recent transactions that haven't yet
been recorded, and that includes not only the transaction
between Dan and Pete, but there may be other transactions
floating out there that took place on the same time.
And the Bitcoin miners will basically
look at all these different transactions at once.
And they're going to basically try
to figure out how to form a transaction block out
of these transactions.
And they want to add this transaction block
to the end of the current transaction block chain.
Now, if you might recall from previous videos, that
for a Bitcoin miner to add a transaction
block to a transaction block chain,
they have to solve what's known as a proof-of-work puzzle.
And the Bitcoin system is designed-- or maybe calibrated
is a better word-- so that on average one miner will
solve a puzzle in about 10 minutes.
I think it's actually worth stressing here
that it could take a long time for any one individual miner
solve the puzzle.
It could even take maybe a year, or even two years.
But because there are so many of these miners working
at the same time, one of them is bound
to get lucky and solve the puzzle quickly.
Now, each of these proof-of-work puzzles
that is associated with a transaction block
happens to have a difficulty score associated with it.
And this difficulty basically represents how hard
it was to solve that proof-of-work puzzle.
So imagine that there are some numbers,
and we'll call these numbers D sub
N. For the most recent difficulty score,
they'll be D sub N minus 1.
These are just numbers that somehow represent how hard it
was to solve this proof-of-work.
And when you look at an overall chain, what the Bitcoin is
interested in is it's interested in how hard was
it to construct that entire chain.
And the reason it's important for someone
to understand how hard the entire chain is constructed
is because this is overall score for this chain--
this difficulty score for the chain
is what's used by Pete or by other people who are receiving
Bitcoins to figure out whether or not
they trust that transaction.
The more work that went into the overall chain, the more trust
they'll have in that transaction.
And the reason for that is that the way Bitcoin works
is that if there was for more than one transaction
block chain out there-- let's say
there was a bad user out there, or maybe somebody didn't
receive a particular message in time,
or whatever reason-- if there's somehow
more than one transaction block chain out there,
according to the Bitcoin protocol,
everyone is just supposed to work off
of the chain that had the most work put into it.
So we ignore chains that have a lot less work
and only consider the chain that had the most work put into it.
And in the Bitcoin system, that particular chain
is often referred to as the longest chain in the system.
And this is actually a confusing piece of terminology.
Because by longest here, we don't
mean that this change is long in any physical sense.
We really just mean-- and I'm going
to put three equal bars to say what it means.
By the longest chain, we mean the change
that has the most work.
And the way that the work is defined
is that you look at all these different difficulty scores,
and these are difficulty numbers, and you add them up,
and that gives you a difficulty score for the entire chain.
And now we're going to be interested in the chain that
had the most work put into it.
And we call that the longest chain.
Now let's imagine that Dan is dishonest
and that after he eats the pizza--
let's say Pete's convinced and he gets his Bitcoin from Dan.
He waits a bit.
He sees that there is a long chain
after that contains a transaction.
He sends the pizza over to Dan.
Dan eats the pizza and then decides
that he doesn't want to behave honestly
and he wants to somehow cheat Pete,
or he wants to defraud the system.
And the way that Dan is going to try to defraud the system
is by attempting to create another transaction in which he
assigns the 5 Bitcoins he got from Carol to somebody else.
And it could be-- let's call this person Fred.
And let's say Fred is basically--
Fred could be Dan's alter ego.
It could be a friend of Dan's.
It doesn't matter who Fred is because we know that Fred isn't
the rightful owner of these Bitcoins.
But what Dan is going to try to do
is he's going to try to take those 5
Bitcoins that he got from Carol.
And he's going to now try to take those 5 Bitcoins
and assign them over to Fred.
And we know that this is something
that we don't want to allow because that would mean
that somehow Dan was able to spend these 5 Bitcoins twice
over.
He's effectively double-spent those Bitcoins,
and obviously one of these transactions
should be considered fraudulent, the other one
should be allowed to go through.
Now, it's important to keep in mind that if Dan just
tried to spend these same coins again
without trying to cover his tracks
or anything of that nature, then everybody out there would
know that Dan is up to no good.
Because they can see from the existing longest transaction
block chain-- namely this existing
chain from the beginning-- they can
see that, hey, Dan already spent these coins
before, he shouldn't be allowed to spend these coins again.
And so what Dan has to do is actually-- on his own--
he has to create a different transaction block
chain that contains just this second bogus transaction in it.
This would be the transaction to Fred.
And that would leave out the other transaction to Pete
and hope that everybody else will start to accept or believe
this newer chain.
And remember that since everyone in Bitcoin
ultimately goes with the transaction block chain that
contains the most work, namely this longest chain
that we talked about, Dan has a fighting chance.
He has a hope, potentially, of being
able to pull off this type of a fraudulent scheme.
And the real question now is, how likely
is it for Dan to succeed?
So for Dan to be able to pull this off,
he has to start off with the transaction block
chain that existed previously.
And he has to try to add to that transaction block
chain a different transaction.
So rather than having this previous transaction where
he gave money to Pete, he's going
to try to create a new transaction
and add it to the transaction block chain that contains
this other fraudulent transaction between Dan
and his friend Fred.
OK.
So this is going to be the bad transaction between Dan
and Fred-- will be in this new block.
And in Bitcoin lingo, this idea is
known as a fork in the chain.
And all we mean by fork is that somehow there
is more than one version of history.
Somebody tried to rewrite their tracks,
or to cover their tracks, and to revise history the way
we know it.
And what that really means is there's now somehow
more than one version of what happened out there.
So in this example, one branch in this fork is legitimate,
and the other branch is bogus.
And the legitimate branch with the one,
in our minds, where Dan paid his friend
Peter this vendor, Pete, for a pizza.
And the bogus one is this follow on transaction
where Dan attempted to pay his friend Fred
with those same exact Bitcoins.
But now remember that any transaction block that's
added to this transaction block chain
has to contain within it a proof-of-work puzzle--
or solution, rather, to a proof-of-work.
Otherwise, no one will accept the chain.
And so if Dan wants to cheat the system,
he has to secretly solve a new proof-of-work puzzle himself.
But the challenge for Dan is that he's starting off
with a bit of a handicap because there's already this longer
chain out there that people have started accepting.
And keep in mind that because this chain is out there,
other nodes may have started to build on top of this chain.
Every 10 minutes, somebody's adding to this change,
on average.
And so there's this longer transaction
block chain out there.
And Dan wants to create his own fake chain.
And so he has to create a chain.
In order for that chain to be believable,
it has to now be the longest chain out there.
And he has to basically do all these proof-of-works
to create a chain that is longer.
And to come up with this longer chain on his own,
Dan has to outrun the existing proof-of-work chain.
And that means he has to solve not just typically
one proof-of-work puzzle, but he may
need to solve several proof-of-work puzzles to create
another chain that he hopes will be longer than the chain that's
out there.
And if he can get the longest chain,
he can get people to start using that chain instead.
And that the chain that he might want people
to use because it contains this fake transaction.
But it removes the previous transaction
where he gave money to Pete.
And to solve a proof-of-work, Dan
has to basically take whatever computing
power he has access to.
And he has to start working on solving
the proof-of-work puzzle.
And there are no known shortcuts for solving these puzzles.
If you recall from any of the proof-of-work videos,
to succeed in a proof-of-work is kind
of like winning the lottery.
There are ways to do it.
But it really depends on how much computing power you have.
The more computing power you have access
to, the more lottery tickets you have.
And if somebody has even one lottery ticket,
they do have a chance to win the lottery.
But they are far less likely to succeed compared to somebody
who has a lot of lottery tickets in hand.
And even if you succeed once in winning the lottery
with a small number of tickets, the likelihood of repeating
that feat over and over again, several times in a row,
becomes much smaller.
But that's exactly Dan has to do.
He has to basically win this lottery multiple times until he
has a bigger chain.
And so the key metric here-- the key thing
you have to look for is how much computing power Dan has versus
how much computing power all the honest nodes in the system
have together.
And if it the case that all the honest nodes-- we'll
call this the honest computing power.
And when I say honest computing power,
I mean the total computing power for all the nodes
who are honest.
All the Bitcoin mining nodes who are honest in the network.
If that total computing power that they have access to
is greater than the power that Dan has access
to-- so Dan's computing power-- then
the Bitcoin system will be safe, because it'll
be hard for Dan to be able to create
this fraudulent transaction chain
because he won't be able to outrun the honest people.
The honest people will win the lottery more frequently
and they'll create a longer chain.
And Dan's attempt is going to be very much an uphill battle.
Now, it's theoretically possible that Dan could have access
to a lot of computing power.
Maybe he's very wealthy or he has a lot of resources.
But he'll really need a lot to be able to that.
More than everyone else who's legitimate combined.
So that's one aspect of why the transaction block
chain is secure.
Because it's unlikely for any one individual to have
access to just that much computing power.
And here I should point out that there is also
another aspect to the security of Bitcoin.
If Dan has access to that kind of computing power
to solve these proof-of-work puzzles,
then rather than trying to fight this uphill battle of forking
the transaction block chain, and creating fake transactions,
and so on, Dan is probably much better
off just using that computing power
he has for legitimate Bitcoin mining himself.
You might remember that Bitcoin miners who
solve proof-of-work puzzles get both a reward for succeeding--
they get some number of Bitcoins--
and they also get a transaction fee
for all the transactions in the block that they validated.
So there's this economic incentive for Dan
to behave honestly.
So maybe I should just recapping in closing
the video that the security of Bitcoin transactions
comes from, first of all, this mathematical barrier that
makes it hard for Dan to fork the transaction block
chain in a dishonest way, as well as an economic incentive
for Dan to just act honestly and mine Bitcoins for himself.