Blockchain 101 - A Visual Demo
Summary
TLDRThis script offers a visual demonstration of blockchain technology, starting with the SHA-256 hash function as a digital fingerprint. It then introduces the concept of blocks, including a nonce to achieve a specific hash pattern, and explains the mining process. The script builds a blockchain, emphasizing its immutability and resistance to change, and illustrates how it can be used to track transactions of a token, ensuring the integrity of financial records.
Takeaways
- π The SHA-256 hash is a digital fingerprint of data that changes with even the slightest alteration in the input.
- π A hash is unique and consistent for the same data input, but it is computationally infeasible to predict the hash from the output alone.
- π¦ A block in a blockchain contains a block number, a nonce, and data, with the hash of the block including all this information.
- π« The hash of a block must meet certain criteria (e.g., starting with four zeros) to be considered 'signed' or valid.
- π The nonce is a number used in mining to find a hash that meets the required criteria for a block to be valid.
- π Each block in a blockchain has a 'previous' hash that points to the hash of the previous block, creating a chain.
- π Changing data in any block will invalidate that block and all subsequent blocks because their hashes will change.
- π‘οΈ Blockchain's immutability makes it difficult to alter past records without re-mining all subsequent blocks.
- π A distributed blockchain means that multiple peers hold identical copies, ensuring consensus and resistance to tampering.
- π° Blockchains can be used to track the transfer of tokens or currency, with each transaction recorded in a block.
- πΈ The coinbase transaction introduces new tokens into the system, similar to mining rewards in cryptocurrencies.
Q & A
What is a SHA-256 hash and how does it function as a digital fingerprint?
-A SHA-256 hash is a cryptographic hash function that produces a unique string of characters, which acts as a digital fingerprint for any given data. It changes with even the slightest alteration in the data, ensuring that the hash is unique to each specific set of data entered.
How does the hash change when you modify the data in the input box?
-The hash changes immediately with any modification to the data in the input box, reflecting the altered content and demonstrating its sensitivity to even the smallest change.
What is the purpose of a nonce in the context of a block in a blockchain?
-A nonce is a number used in the mining process to vary the hash of a block until it meets certain criteria, such as starting with a specific number of zeros. It is part of the trial-and-error process to find a valid hash for a new block.
Why is a block considered 'signed' in the blockchain demo?
-A block is considered 'signed' when its hash starts with a specific pattern, such as four zeros, which is arbitrarily chosen in the demo. This indicates that the block has been successfully mined and meets the required conditions.
How does changing information in a block affect the blockchain?
-Changing information in a block alters its hash, which in turn affects the 'previous' hash of the subsequent block, invalidating the chain of blocks from that point onwards. This demonstrates the integrity and immutability of the blockchain.
What is the process called when trying to find a number that results in a hash starting with four zeros?
-The process is called mining. It involves trying different nonce values until a hash that meets the criteria is found, which confirms the block and adds it to the blockchain.
How does the blockchain resist changes or tampering with its data?
-The blockchain resists changes because each block contains a hash of the previous block's data. Altering any information in a block would require re-mining not just that block, but all subsequent blocks, making it computationally impractical.
What is the significance of having multiple copies of the blockchain across different peers?
-Having multiple copies across different peers ensures the integrity and consensus of the blockchain. It allows peers to quickly verify the validity of the chain and detect any discrepancies, thus preventing tampering.
How does the concept of a coinbase transaction introduce tokens or money into the blockchain?
-A coinbase transaction is a special type of transaction that 'mints' new tokens or money out of thin air and assigns them to a specific entity, like Anders in the demo. This is the initial source of funds in the blockchain before any transactions occur.
Why is it important to track the provenance of tokens in a blockchain?
-Tracking the provenance of tokens ensures that each transaction is valid and that no money is created out of thin air. It allows for the verification of the history of each token and maintains the integrity of the currency.
What is the role of immutability in the context of a blockchain used for transactions?
-Immutability ensures that once a transaction is recorded in the blockchain, it cannot be altered or deleted. This is crucial for maintaining a reliable and trustworthy record of transactions, especially for financial transactions.
Outlines
π Introduction to Blockchain and SHA-256 Hashing
This paragraph introduces the concept of blockchain technology with a focus on the SHA-256 hash function, which serves as a digital fingerprint for data. The hash function is demonstrated with a visual example, showing how altering data results in a changed hash. The hash's uniqueness and the process of mining a block, which involves finding a nonce to produce a hash starting with four zeros, are explained. The paragraph concludes with the idea of a 'block' containing data, a nonce, and a block number, which is hashed to verify its integrity.
π Understanding the Blockchain Structure and Immutability
The second paragraph delves into the structure of a blockchain, illustrating how each block contains a hash of the previous block, creating a chain. The immutability of the blockchain is highlighted by demonstrating the consequences of altering data in a block, which invalidates the block and all subsequent blocks due to the changed hashes. The concept of distributed blockchain copies is introduced, showing how peers on a network maintain identical copies of the blockchain and can quickly identify discrepancies.
π° Implementing Tokens and Transactions on the Blockchain
In this paragraph, the script introduces the use of tokens and transactions within a blockchain. It explains how transactions, such as transferring money, are recorded on the blockchain, emphasizing the importance of immutability for maintaining accurate records of financial transactions. The paragraph also touches on the concept of coinbase transactions, which are used to create new tokens out of thin air and distribute them to a particular address, simulating a reward mechanism in a real-world blockchain system.
π Tracing Transactions and Ensuring Blockchain Integrity
The final paragraph discusses the ability to trace transactions on the blockchain, ensuring that each transaction is valid and that no money is created out of thin air. It explains how the blockchain's structure allows for the verification of each transaction's legitimacy by tracing back through the chain. The paragraph concludes by emphasizing the resistance to tampering and the importance of maintaining an immutable history of transactions, which is a key feature of blockchain technology for secure and transparent record-keeping.
Mindmap
Keywords
π‘Blockchain
π‘SHA-256 Hash
π‘Fingerprint
π‘Block
π‘Nonce
π‘Mining
π‘Immutability
π‘Transaction
π‘Token
π‘Coinbase Transaction
π‘Distributed Ledger
Highlights
Introduction to blockchain technology through a visual demonstration.
Explanation of SHA-256 hash as a digital fingerprint for data.
Demonstration of how the hash changes with even the slightest alteration in data.
Illustration of the hash's consistency for identical data input.
Introduction of the concept of a 'block' in a blockchain structure.
Description of the 'nonce' as a variable number used in the mining process.
Process of mining to find a nonce that results in a hash starting with four zeros.
The importance of the 'previous' hash in linking blocks in a blockchain.
Demonstration of how altering data in a block invalidates the entire chain.
Explanation of how blockchain resists mutation and maintains data integrity.
Introduction to the concept of a distributed blockchain across multiple peers.
How consensus is achieved in a distributed blockchain through hash verification.
The use of blockchain for token transactions and maintaining an immutable ledger.
Demonstration of a coinbase transaction to introduce new tokens into the blockchain.
The significance of tracking the provenance of tokens in a blockchain.
The role of blockchain in resisting tampering and ensuring the integrity of currency transactions.
Overview of the practical applications and benefits of using a blockchain for transactional records.
Announcement of a follow-up part 2 for further details on transaction creation.
Transcripts
this is a blockchain demo
we're gonna do this in a very visual way though
we're gonna make it very easy to understand
by stepping through the key pieces of
what a blockchain is in a visual way but
before we get started we need to take a
look at this thing that we call a sha
256 hash
ok and a hash this is this is one of
them right here
hash looks like a bunch of random
numbers and essentially what it is it's
a fingerprint of some digital data and
it just so happens it's a fingerprint of
whatever i type in this box
so if I type my name "anders" into
this box you see that the hash has
changed matter of fact it changed every
time I typed a letter right so I'm going
to go back to so it says anders okay so
this is a the hash of the name anders
all lower case it starts with 19ea
right
ok so if i delete that and I go again
type anders again you can see it starts
with 19ea the same exact hash in that
sense it's a digital fingerprint of this
data whatever data is here every time
you type exactly the same data you get
exactly the same hash and i can type
anything i want so I can you can have
nothing like this you know e3b0
that's that's the hash of nothing or you
could type tons and tons of stuff a
matter of fact you could put like the
library of congress in here and you
would get a hash and the interesting
thing about it is regardless of their if
there's a tiny amount of information no
information or the entire library of
congress you're always going to get a
hash that is this long this many
characters are you not going to be able
to pre guess what this is you kind of
have to put the library of congress in
here to figure out what the hash is but
you you'll always get exactly the same
hash regardless of how many times you
put exactly the same information in so
what I'm going to do is extend this idea
of a hash
into something that we're going to
call a block
alright so let's take a look at a block
so this is a block and it's exactly like
the hash it's just that data section
I've broken out now into three sections
one called block this is just some kind
of a number this block number 1 a nonce
which is just yet another number will go
into what that is in a second and then
just some more data just very similarly
to the way that we had it before
however the hash of this which includes
all of this information up here is down
here and it begins with four zeros you see that
it's a relatively unusual hash you know
most of them are not really going to
start with four zeros like that but this one
happens to and because it does totally
arbitrarily i'm going to say that this
block is signed
ok so what would happen if i were to
change any one piece of this information
let's say if i were to type something here
right the hash is going to change and
what's the chance of that if i type
letters this hash is going to start with
four zeros pretty low it's probably not
right so let's see what happens when i
do that i'm just going to say hi
look at that right this hash does not
start with four zeros and so the big
background here has turned red
so now you know that this this block
with this information in it is not a
valid or a signed block ok and that's
where this nonce comes in this
nonce is just a number that you can set
to try to find a number that fits so
that this hash starts with four zeros again
alright so how do we do that well let's
start with one that start with now it's
32 so that's not one let's try two FF
now
3 4 5 6 so you get the idea like i
could sit here all there's one that
starts with 0 I can sit here all day
typing these numbers and trying to
figure out one that actually is going to
hash out to something that starts with
four zeros that wold take a long time so
here i have my little
mine button i'm sure you've been wondering
what happens if i press that so what's
going to happen when i press this mine
button is it's gonna run through all the
numbers from 1 all the way up to try to
find one where the hash starts with four
zeros and this process is called mining
let's do it right now
now it's checking all of the numbers
from 1 all the way up with their now
it's stopped at 59,396 and that one
just happens to hash out to something
that starts with four zeros and it
satisfies my little definition of what
assigned block is ok so that's that's a
block now can you tell me what a
blockchain is it's probably just a chain
of these blocks well how do you how do
you put them together let's let's do
that
alright so here's my blockchain I've
blocked number one has some kind of
a nonce just like before there's some
data area too but then it has this
previous here is a bunch of zeros let's
let's roll forward so this is block
two and block 3 and 4 this block chain
has five blocks on it right the previous
here starts with 0000ae8 right is
this number
ae8 and then this previous you know b90 is this one
over here b90 so you can see that each
block points backwards to the one before
it
you remember that that first block over
here
there actually is no previous so it's
just a bunch of zeros it's actually just
a fake number
ok so just like we did before what
happens if I change some information
here right it's going to change the hash
of this block and it's going to
invalidate it right now let's try that
so i'm going to type pie again sure
enough that block is invalid
alright just as we assume but what would
happen i'm going to fix that now we'll
go back to something that work what
would happen if I changed something in
this block right it's going to change
this hash
but this hash gets copied up to this
previous so it's going to it's going to
change this one to right so it should
break both blocks so let me try typing
hi in there and sure enough all right so
we can go back as far as we want you
know to some point in the past and
break that block and it will break all
the blocks since then everything before
still green but this one is is red it's
so if i wanted to you know change
something in this this block chain I
could just go over to block number five
right here we could change it I'll put
hi and then we could remine it you
know and pick a different nonce will do
that right now and we could essentially
alter the chain so we've done it so that
we should be good down right all right
well what happens if i go back in time
to hear and I break it here now i have
to mine this block which will pick a
nonce that makes this block hash out to
four zeros if we can find one sometimes
it takes a while because it's gotta run
through a lot of there it is it found
one at a hundred and thirty-eight
thousand alright but this one is still
broken because although this one starts
with four zeros adding the four zeros with
different stuff up here still makes this
block hash out incorrectly so i also
have to mine this block
alright and that takes some amount of
time that one was a little bit quicker
and then i have to mine this block to
fix it
alright so what we're showing here is
that if i go and change this last block
all i have to do is remine this block if
I go way back in time to back here and I
make a change like that i'm going to
have to mind this one this one this one
and this one so the more blocks that go
by the more blocks in the past that we
are the harder and harder and harder it
is to make a change and so that
it's how a blockchain is going to resist
mutation resist change
ok so now you like like you know
identify if if i do this in this block
here you can see that I've changed it to
hi and I remine it blah blah blah how
would i know that my block chain has
been remined all right let's take a look
at that I'm gonna hit this little
distributed thing so now we have a just
distributed blockchain it looks exactly
like the last blockchain ok up to five
that but this is peer a the first peer
if you go down here you can see here is peer b
and it happens to have an exact copy of
the blockchain there's actually also
a peer c down here right this could go
on forever
there's many many peers out on the
internet and they all have a complete
copy of the blockchain so in this case
if i look at this hash it's 0000e4b
all right if I go down to this one I
notice it also has e4b if I go
down to this last one it has e4b so they
must be identical and i'm going to
demonstrate that by going here and
typing something i'll type hi again and
then i will remine this block
I've got some other number now let's put
some other number up here so i should be
able to mine this block
okay now all the chains are green right
they're all green
however this chain says the last hash is
e4b the bottom one says that too e4b
and this middle one here says 4cae
so I know just by glancing at this one
little hash that something is wrong in
this blockchain even though all of the
hashes start with four zeros I know that this one
is different and it's different because
i have two it's essentially two against
one we are a little democracy here right
this guy argues that it's
e4b this guy argues that it's
4ca and this one is e4b
so e4b wins so that's how a
completely distributed copy having a
copy on many different computers they
can all very quickly see if all of the
blocks are identical remember
blockchains can have you know 4
500,000 blocks very easily so rather
than checking through all of them all
you really have to do is look at the
hash of the most recent one and you can
see that if anything in the past
anything way back here was altered you
can tell by looking at this at the last
block in this in the chain you know it's
going to hash out to something that
doesn't start with four zeros and looks
very different from what the hashes on
the good chains are ok so that's a
blocking that's the entire thing there
is no more to it than that but it's kind
of not really useful because we don't
have some something in this data area
that means anything i keep typing my
name or hi and that's kind of that sort
of irrelevant information so what we
really want is a token so let's do a
token on our blockchain all right now
look at this so i have this token just
totally arbitrarily I'm calling these I
guess dollars right so we have
twenty-five dollars from Darcy to
Bingley four dollars and twenty-seven
cents go from Elizabeth to Jane you get the
idea it's basically there's all these
transactions that are happening and I've
just replaced the data with these
transactions and just like we saw before
you know so there's multiple blocks here
this one has more transact... it doesn't
matter how many transactions there are
there can be many or there can be few or
none if we keep going forward here just
like we saw before
if we go down and we notice we have all
these other copies of the same block
chain right so now here's where the
immutability is important if i change
something back here you'll notice that
this is you know a7fc blah blah blah
something it's something else
so it's something different than what's
down here so in in this way I mean it's
very important that if i were to go back
in time and change some value that we
would notice it's it's very important
with money that you don't lose track and
that's the whole point of using a
blockchain here this is a whole point of
resisting any kind of modifications you
know of things that have happened in the
past so that's the that's the reasoning
behind having using a blockchain to
remember tokens now I one thing I would
mention here is that we're not listing
you know Darcy has a hundred dollars and
he's giving 25 of it to Bingley the only
thing we're saying is Darcy gives 25 to
Bingley. We're not remembering a bank
account balance we're only remembering
money movements. So this begs the
question "does Darcy have $25?" Well we
have a problem here in this version
of the blockchain: we don't actually know
if Darcy has $25. So let's look at a
coinbase transaction. So if we look back
here a coin base we're going to add a
coinbase transaction to our blocks and
this is this is very similar to what
we've seen before but we're just adding
a coinbase at the top and what's that
that what that's saying is we're going to
invent a hundred dollars out of thin air
and give it to Anders and there's no
transactions in this block because
nobody had any money previous to this. In
the next block another hundred dollars
comes out of nowhere and goes to Anders i'm
a fan I love it right I'll take a
hundred bucks now we have some
transactions you can see that they're
all from Anders, they're all from me because
I'm the only one who has any money at
this point. So I'm sending 10 of my
dollars to Sophie. Do I have ten dollars?
Yeah, I do, I look back and I see that
this coinbase transaction has given me a
hundred so I have at least 10 and I can
send it on and you add all these up and
they don't go
over a hundred and it follows sort of a
basic rule of a currency that you
can't invent it out of thin air you can't
create money out of thin air you this
its dispersion is controlled so now if
we look at this block chain that we've
created and we zip forward in time and
we notice that we see that Jackson is
giving Alexa two dollars and so does
Jackson actually have two dollars to
give Alexa well we go back a block
before we see that Emily had gotten ten
dollars from Anders gave 10 to Jackson
and so Jackson does have the money so we
can just go backwards and and find that
out
that's actually one of the benefits of
having a previous here it's easy to go
backwards we we just look for the block
that looks like that that has that hash
and here it is right here right so you
points two blocks back in time and
allows us to trace the provenance of any
coin that we want
so that's a basic block chain and we're
running a currency on top of it and as
you know blockchains are there many
copies everybody has a copy of it so if
we mutate you know this and make it six
dollars these go invalid it does not
agree with with these block chains down
here these copies of the same block
chain down here so this resist tampering
which is what you want for a currency it
works very well for things that are
small and transactional like this
go ahead and fix that and they're
just a very efficient way to
handle agreement on what has happened in
the past as kind of this immutable
history that that goes down with
time so that's a basic block chain and a
token on it there were glossing over
some main points but if you dig into the
demo and and click through these things
and
play around with it you get a better and
better idea of how this works there will
be a part 2 where we go into a little
bit more detail about how the
transactions are created till then
Browse More Related Video
Blockchain Technology - CompTIA Security+ SY0-701 - 1.4
What is a Cryptographic Hashing Function? (Example + Purpose)
Digital Signatures and Digital Certificates
Blockchain In 7 Minutes | What Is Blockchain | Blockchain Explained|How Blockchain Works|Simplilearn
Blockchain Hashing Explained! (You NEED to understand this)
CHE COS'Γ E COME FUNZIONA UNA BLOCKCHAIN | #TELOSPIEGO
5.0 / 5 (0 votes)