Blockchain Basics

Blockchain and Bitcoin are 2 different things:

Bitcoin is first decentralized digital currency, proposed by ‘Satoshi Nakamoto’ in year 2009. Bitcoin uses peer-to-peer technology to operate with no central authority or banks. Managing transactions and issuing of bitcoins is carried out collectively by the network, where as
Blockchain is the technology that enables moving digital coins or assets from one individual to another individual.

What is Blockchain?

A Blockchain is a decentralized, distributed and public digital ledger used to record transactions across many computers so that the record cannot be altered. A blockchain database is managed using peer-to-peer network and distributed time stamping server.

blockchain

blockchain_working

Block: Block holds the transaction data. Each block contains hash of previous block. This has the effect of creating a chain of blocks from first to current block.
block

Each network has its own defined block time, for ex in Bitcoin network time needed to generate and add a new block to chain is 10 minutes.

If anyone tries to tamper any block then it will change it’s hash value, and all the blocks following it are not valid.

Hash is also not enough because after tampering if all the blocks (blocks following the tamper block) are re-processed then chain will be valid again. So to stop this blockchain has concept of Proof Of Work.

Features of Blockchain:

  1. Distributed Ledger: Distributed ledger technology is a digital system in which transaction and their details are recorded in multiple places at the same time.
    Unlike traditional databases, distributed ledgers have no central data store or administration functionality.
    distributed_ledger
  2. Peer-to-Peer network:  Peer to peer network is one in which two or more PCs shares files and access to devices. It maintain consistency of distributed ledger. There is no centralized database copy.
    p2p_network
  3. Proof of Work(PoW): This is the most popular algorithm being used by currencies such as Bitcoin and Ethereum.In Proof of Work, in order for an actor to be elected as a leader and choose next block to be added to blockchain they have to find a solution to a particular mathematical problem.These actors are also known as miners. It is very hard to find a solution for given problem. Whenever a new block is mined, that miner gets rewarded with some currencies. Other nodes verify the validity of block by checking that hash of the block is less than a preset number (Every network has a global block difficulty, every block must have hash below this target).
    proof-of-work


Miners: Blockchain data is maintained at various nodes known as miners. Miners work is to use his resources to validate the block containing transactions and add it to chain.

Type of Blockchain:

  1. Public Blockchain: Public blockchain has no access restrictions. Ledgers are visible to everyone and anyone can verify and add a block of transactions to blockchain. For eg: Go Ethereum and bitcoin blockchain.
  2. Private Blockchain: Private blockchain is permissioned. One cannot join it unless invited by the network administrators. Only the invited people are allowed to verify and add blocks to chain, but everyone is allowed to view the ledger records.
  3. Consortium Blockchain: It is said to be semi-decentralized. Only group of organizations are allowed to verify and add blocks to chain, ledger can be open or restricted to group of peoples.
    blockchain_types

Blockchain use cases:

  1. Banking:
    Issues with current banking system:
    -> High transaction fees
    -> Double spending
    -> Frauds and account hacking
    -> Financial crisis and crashes How blockchain solve these issues:
    -> Decentralized System
    -> Public Ledgers
    -> Verification of every individual transaction
    -> Low or no transaction fees
  1. Payment & Transfers:
    -> Secure
    -> No transaction fees
    -> No bank account needed
    -> Anonymity is maintained
  2. Healthcare: Use to store details of patients, this ensures that anyone who have access to blockchain can access the details of patients. This is highly secure, no one can access the details without knowing the persons public key and cannot make any changes.
  3. Law enforcement: Blockchain is highly secure way to maintain the details of crimes and criminals.
  4. Voting: Election requires authentication of voters identity, secure record keeping, tracking & counting votes without voter fraud, voters can vote from any place which will increase voter turnout.
  5. Real Estateblockchain_usecases

 

What is Genesis Block?

The Genesis block is the first block in the chain, the Genesis file is a JSON file that defines the characteristics of that initial block and subsequently the rest of the blockchain.

Configuration:

{
“nonce”: “0x3”,
“timestamp”: “0x0”,
“parentHash”: “0x00000000000000000000000000000000000000000000000000000”,
“extraData”: “0x0”,
“gasLimit”: “0x4c4b40”,
“difficulty”: “0x400”,
“mixHash”: “0x00000000000000000000000000000000000000000000000000000”,
“coinbase”: “0x000000000000000000000000000000000”,
“alloc”: {
}
}

-> extraData: Extra 32 bit memory that you can use to pass any message.
-> difficulty: how difficult it would be to mine a specific block as part of that blockchain.
-> coinbase: coinbase is a address to which coins have to be send after the block has successfully been mined.
-> parentHash: Hash code of a parent block. As genesis block is the first block of the chain so it will be set to 0.
-> mixHash: It is a key value which will be kept same for your blockchain.
-> nonce: nonce is a key value that is computed by all miners
-> gasLimit: Limit of resource that one can spend to mining a block
-> alloc: Alloc defines the list of pre filled wallets

Combination of nonce and mixHash is known as Proof-of-work.

You need to get a specific hash value with a combination of nonce and mixHash which is less than the set value for a block, how this value is defined has a certain mathematical logic associated with that.

Basically we need to identify the value of nonce, once you add it to mixHash the value should be equivalent or lesser than the mathematical value set for that block. This is where resource gets invested, the value of nonce is something which you get by trial and error method.