Working principle of Blockchain technolgy
Blockchain being a data base and having list of records called blocks linked by cryptocurrency is distributed among all nodes works in a peculiar way.
Nodes are the active electronic devices (may be computers, laptops, phones etc) that are connected to blockchain network. They are part of the widespread network of blockchain.
In general the role of a node is to maintain, support and process the trustworthy information (or) transaction (or) services of the blockchain network. Those need to be in line with the predefined consensus protocol of the distributed ledger.
A specific node is a node that possesses the same responsibility as nodes do but with an additional important activity called mining.
Mining is the process of inserting valid or verified blocks to the blockchain network by resolving the ‘Proof of Work’ algorithm within the earliest stipulated time set by the concerned crypto currency. Mining process is done by miners who are acquired with lots of computational resources and power to get through Proof of work.
Its highly impossible for an individual to attain computational resources like high end CPU’s or GPU, heavy ram, high speed processors and hardware along with heavy electricity to reach mining.
Proof of Work:
Proof of Work is the most popular consensus algorithm used by crypto currencies to pose mathematical problems to a miner while mining. The approximate time frame of mining is 10 min with in which the earliest problem solved miner is rewarded and get a chance to add his block to the chain.
Proof of work takes Merkle root, timestamp, previous block hash, nonce as an input to pose the mathematical problem. If at all the output result in hash of a particular miner is smaller than the target hash within the time frame at the earliest of the competitors, then that miner is the first one who won his block in the blockchain
In general hashing ensures transaction or block safety from editing point of view, where as proof of work ensures block safety by the mining process which requires heavy computational source.
The mathematical riddle posed by may be like
Hash (‘something’ + block data) = Output
Output – Given Output
block data – Data of block developed by miners
‘something’ – The value to be found out by miners
Hash – A mathematical function by Bitcoin
Hashing is the backbone of blockchain that ensures safe, secure and trusted network. No chances of fraudulent activities, double spend or acceptance etc is seen under this.
Hash is a mathematical function used by the crypto currencies to provide a unique hash code or function for each and every transaction or a whole block. It encrypts any arbitrary size in to a fixed length of strings and characters.
Essentially a hash code is designed in such way that even a minor change in the original transaction affects the hash code so drastically and is very incomparable with the earlier one. A hash code generated depends on several factors like transactions of a block, hash code of previous block etc which is unpredictable.
Integrity and continuity of blocks in the chain are maintained by placing the hash of each block in the subsequent block. In general the hash code appears in the header of the every block.
Example: Variation of a hash code on changing a single letter of a word is shown belw
If anyone tries to change the data in a transaction of a particular block, the change is immediately reflected in the hash code following the changes in subsequent hashes. Owing to its different properties, hashing makes every tampering to be very crucial.
Relatively generating hash for a block is not such infeasible, but it is quietly infeasible to estimate what data is considered for generating hash sequence. Furthermore previous block hash code is also included making it stringent.
Properties of hashing:
- Hash code remains unchanged for a particular input.
- Nevertheless the multiple entries of same input in hash do affect the output code. Even the same is necessary to keep track on the authenticity of inputs too.
- Never ever produces same output for different hash input.
- Quick computation: The hash function should be capable of returning the results quickly.
- Puzzle friendly: Selection of concatenated input of hash ejects the probability of end results in the process of mining
Cryptographic Hash Functions:
- SHA-256 : Produces 256bit hash and used by Bitcoin.
- Keccak-256 : Produces 256bit hash and used by Ethereum.
Blockchain adds a variance called nonce in each block. This nonce is like a salt added to the contents of a block. Due to the introduction of nonce, the hash output of the contents of the block will change.
Miners try to trace this nonce (number used once) to increase the probability in solving the puzzle. Note, the hash of the contents of the block being mined should start with a specific number of leading zeroes. The difficulty in solving the puzzle lies in the number of leading zeroes to achieve in a hash code. There is no standard to calculate a nonce, it has to be done by trail and error.
Rewards or awards are counted in the form of digital currency or crypto currency. A miner is eligible to charge the transaction fee in the form of Bitcoins (a type of crypto currency) for placing or creating a block in the chain from the others.