Skip to main content

Blockchain 101 for Developers - Part 1 - Concepts

What problem does Blockchain address?
(In very simple terms) Blockchain primarily addresses aspects of record keeping across multiple, distributed peers such that trust between them is no longer an issue and no central authority is needed either.

Somewhat more formally, blockchain is an immutable, distributed ledger of transactions.

In today’s world, each organization/ peer participating in a business network performs its own bookkeeping of facts of interest. For example, a car manufacturer would have its own data related to the cars manufactured and a car distributor/ reseller will have its own data---even through there are overlaps and they might be talking about the same asset (i.e., a specific car). Same goes for financial institutions---each bank will have its own data. Such silos definitely need either central authorities/ middle-man who everyone can trust as well as settlements and reconciliation processes to iron out conflicts.

Blockchain addresses all these problems by acting as a distributed ledger, which everyone can trust and have access to.

Bitcoin uses blockchain to record facts related to “coins” and their “transfers”; the interaction is from peer to peer and there is no central authority. But the technology itself is much more than what I have just stated.

How does blockchain do that?
Blockchain is, no pun intended, blocks chained together. Each block contains certain facts, and the entire chain is (usually) replicated across all peers and it is immutable.

For people with data structures (computer science) background, the chain can be thought of as a doubly linked list with an additional property of immutability.

Blockchain Conceptual


Immutability? What? Why?
Immutability means that you cannot practically change a block, once it is added to the chain. This is achieved by using hash functions (one-way functions from cryptography). Each block contains a hash value generated from the facts in that block as well as the hash of the previous block. Therefore, modifications to a block is not possible unless all blocks from that point onward are rewritten, which is not feasible as other peers also contain a copy of the entire blockchain.

Since blockchain is immutable, nobody needs to worry about fraud/ trust issues as long as no participant has more than 50% of the computational power in the network; more on that later.

In addition to immutability, blockchain also implicitly means decentralisation by employing a consensus protocol.

Consensus? On what and how?
Consensus on which block gets added next to the chain. In bitcoin, this is achieved by using some aspects of game theory and is termed as proof of work. All peers compete to add the next block to the chain and they have to solve a (useless) mathematical puzzle with each block they want to add to the chain. Solving this puzzle is a computationally intensive work and introduces a sort of randomness to who among all the peers gets to add the next block. Whoever creates a valid block broadcasts it to everyone else. In bitcoin, the peer who successfully creates a new block is said to be a miner and they are rewarded with some fresh bitcoins (said to be mined in the process).

So what is this "miner fee"? And what is the "reward"?
There are between 1500 and 2000 transactions in a Bitcoin block (and this may change in the future). Transaction 0 of each block is a special transaction that gives miners their reward. Unlike other transactions, this one doesn't have any input and yet it generates Unspent Transaction Output (UTXO). The reward is currently set to 12.5 BTC per block.

Additionally, the originator of a transaction gives incentive to the miners to include their transaction in the next block. Each transaction includes a "fee" that is given to the miner when the transaction is included in a valid block added to the blockchain.

Somewhere I read that blockchain participants are anonymous?
Yes, although there are many variations depending on the nature of the blockchain. In Bitcoin, for that matter, the participants are anonymous by design, as the blockchain is public by design. Participants can join the blockchain without proving who they are, and there is no central authority managing the "registration" process. Public key cryptography along with hashing are the backbone of the blockchain; they ensure integrity and prevent forged transactions.

Public key cryptography; you mean RSA?
Not exactly. Bitcoin and Ethereum, for example, use Elliptic Curve Cryptography; it gives you smaller sized keys.

Can I see what a block looks like?
Of course. The ledger in public blockchains is public. You can find the genesis (i.e., the first ever block) of Bitcon here and that of Ethereum here.

What's the catch? Why not build everything on blockchain?
As a technology, it's still in infancy. But more importantly, unless you are creating a disruptive solution, it doesn't make sense to use decentralization where the solution requirements dictate centralization. Decentralization is hard, and it's inherently slower if consensus protocols need to be developed. Bitcoin's proof of work, for example, adds a new block every 10 minutes or so. This means that your payment to a peer would take at the very minimum 10 minutes, and practically, it takes much longer than that! This is way too slow as compared to modern banking systems, which process thousands of transactions per second.
Don't use a blockchain unless you really need it.
Is that everything I need to know at a conceptual level?
There is a lot more--there is proof of stake in addition to proof of work; there are pre-mined coins, private blokchains and smart contracts, and then there are tons of cryptocurrencies and businesses created on top of the simple concepts made popular by bitcoin.

Comments

Popular posts from this blog

Blockchain 101 for Developers - Part 2 - Smart Contracts (concepts)

I have heard of Bitcoin but what is Ethereum? While bitcoin (traditionally) allows simple addition and subtraction operations, which are sufficient for exchange of cryptocurrency, Ethereum enables more sophisticated operations. Ethereum positions itself as a programmable blockchain . Ethereum takes the blockchain concept popularised by bitcoin and introduces a full Turing-complete virtual machine on top of it. The machine is capable of executing code, which is usually written in Solidity programming language. But what does it do? Most commonly, the programmable code is termed as a smart contract ; it establishes conditions under which things of value are exchanged. In other words, instead of using a traditional legal framework to bind two parties, there is code deployed within the blockchain which automatically enforces an agreed contract. The contract could be as basic as "money is transferred from an escrow account to Alice's account, only when today is a Sunday...

What are Merkle Trees and why are they important for blockchain?

What are merkle trees? Let's start with the basics by brainstorming a solution to this problem: How can you compare two copies of a large file across two machines? A naive approach would be to send the file from one to the other machine, and compare the contents using a sting matching algorithm. Let's do a little better with the understanding that utilizing CPU time locally is cheaper than sending something over the network . A better approach would then be to generate a hash value (i.e., a checksum) from each of the two files and compare the results. This approach starts making even more sense as you increase the number of machines on which the file is replicated and comparison needs to be performed--each machine can generate a checksum and share the results. Now, let's ask another question: "When you find differences in the hashes generated for file comparison, how can you quickly find out which part of the file is different?" This is more challengi...