Will blockchain and cryptocurrencies lead to a decentralized utopia while opening up new use cases, applications and other vistas or will it be a bubble that will burst?
That is an open question which I would like to skip for now, as such speculation could limit our understanding of the fundamentals.
Though not required to continue reading (and I tried making it as simple as possible), it may help to brush up on concepts like public key cryptography and cryptographic hashing.
Blockchains use cryptography not to encrypt or securely send messages but to secure transactions, so that people don’t steal from each other and/or impersonate others.
So, what is a blockchain and a crypto currency like Bitcoin?
Let’s use the famous duo Alice and Bob. Alice would like to send $10 to Bob. Of course, they can use a traditional bank but if you want to eliminate the middleman, read on. The money here is represented in a string of bits (not any different when doing a wire transfer).
How can we prevent Alice from using the same string of bits to pay David?
How can we prevent another person from using the same string of bits, impersonate Alice and take money?
How can we prevent Alice from denying later that she intended to pay Bob?
The steps involved in securely committing the transaction to the chain/public ledger are as follows:
Alice signs the string of bits to transfer the money with her private cryptographic key and then broadcasts the message to the entire network.
Bob can verify using Alice’s public key, as the person who signed that message.
Alice cannot later deny creating that message as she used her private key that nobody else has.
What if Alice sends the same message 20 times to Bob? Did she intend to send $10 twenty times?
Alice needs to add a ‘serial number’ (transaction hash) to the message to avoid the above problem.
Before Bob can accept the transaction, he would like to check if Alice has $10 to spend. He asks all the blockchain participants to check. Everyone in the network has a copy of the latest ledger, they can confirm or deny.
What if Alice controls the majority of the network and her bots respond that she has the money?
This is where the concept of Proof of Work (PoW) enters the picture. More details in a later post.
PoW makes it computationally costly for network users to validate the transaction (this will make it extremely hard for Alice’s bots to fake validate)
As PoW is computationally hard and costs electricity, network’s users are rewarded when they validate a transaction (block) with crypto currency like bitcoin or ether.
Validating process is called mining and the reward is a bitcoin or ether.
The order of transactions is critical to avoid double spending as an example.
Each block can have multiple transactions (dozens or hundreds).
In addition to having transactions, each block has a pointer (hash of the previous block) to the last validated block in the chain. Thus the name blockchain.2
When one tries to change a value in the already committed transaction, it changes the hash of the block which will require to change the hash of the next block which has it as a pointer. This will trigger a need for a cascading change in other blocks. This is next to impossible to pull off (unless you control processing power greater than that of the network). Thus blockchain transaction are called immutable (cannot be updated later).
Once the miner solves the puzzle successfully, the block is added to the blockchain. The miner gets a bitcoin or ether as a reward.
Alice paying Bob is now committed to the chain.
I have skipped a lot of details and potentially important bits like accounts, addresses, wallets, alternatives to PoW, genesis block, contents of a block etc which I will visit at a later time.
Source: Ethereum.org
Merkle Trees are a fundamental part of what makes blockchains tick.