Understanding the Blockchain

in #blockchain7 years ago

Hey Steemians,

So today I’m going to be talking about how the Blockchain works.
I’m just explaining a little bit about what I understand from some of the great videos that I watched from @ivanli. So if you guys want to learn more about all these different blockchains, please follow @ivanli and check out all of his cool videos on his steemit page. I will try to keep posting reviews about them for you guys
Before we can understand the Blockchain we need to understand 2 things.

• What a Hash function is and how it works
• What a Merkle trees is and how it works

Hash – A hash function is a one way function meaning it can take an input (an input is always a sequence of bits). So the hash function will take that input and apply the hash function to produce a fixed value as an output. However if you change only one bit, the whole output will be completely different.
This is a one way function, there is no way for you to figure out the input if you only have the output, so if you have the input you can get the output, if you only have the output there’s no way to get the input. So this is how a Hash function works.
The next thing we need to understand is a Merkel tree.

Merkle tree – A Merkle tree is a data structure where each layer is a combination of hashes. Merkle trees are binary trees containing cryptographic hashes. ... A Merkle tree is constructed by recursively hashing pairs of nodes until there is only one hash, called the root, or merkle root. This is the cryptographic hash algorithm used in Bitcoin or in other blockchains.

Hash_Tree.svg.png

Ok so now we can start talking about the Blockchain.

Blockchain – The Blockchain is basically a huge merkle tree. New blocks get created by combining the root hash of the previous block, plus the hashed merkle tree of the current transactions being processed and a value call ‘nonce‘ which altogether are hashed in an attempt to get a new hash that is lower than the current difficulty of that particular blockchain.

Only when a hash lower than the difficulty number gets achieved, a new block is created, and the computer that resolved this block gets rewarded with new coins.

The blocks are added to the blockchain in a linear, chronological order. Each node (computer connected to the Bitcoin network using a client that performs the task of validating and relaying transactions) gets a copy of the blockchain, which gets downloaded automatically upon joining the Bitcoin network. The blockchain has complete information about the addresses and their balances right from the genesis block to the most recently completed block.

Blocks, meanwhile, are like individual bank statements. The blockchain has records of every Bitcoin transaction ever executed. It can thus provide insight about facts like how much value belonged a particular wallet at any point in the past or present.

This is what I like about blockchains, the fact that there is no way you can fake or hack a transaction, since if you do that, the whole merkle tree will change, and the latest block wouldn’t match across all the nodes of the network, so any fake transaction will always be easily detected. In this way everyone can have consensus over all the transactions and nobody can claim coins that they don’t own.

At least that’s the way I understand it so far… Still learning and watching vids about the whole thing.
Please feel free to comment if I got anything wrong

Enjoy!

Sources:

https://steemit.com/blockchain/@ivanli/programmer-explains-merkle-tree-or-blockchain-technology

https://steemit.com/blockchain/@ivanli/bitcoin-hashes-are-just-numbers

https://steemit.com/blockchain/@ivanli/what-is-inside-a-bitcoin-block-programmer-explains

(I guess @ivanli didn’t uploaded this one on steemit yet)