Learn Today The Complete Beginner Guide to Blockchain by Prof. Naveen Kandwal

Complete guide on blockchain in india
Complete guide on blockchain | blockchainblogging.com

A Block Chain, is a list of records, called blocks, that are linked using encrypted address. Each block contains a encrypted hash of the previous block, a timestamp, data, and transaction data. After completing this beginner guide to Blockchain (Block Chain) you will be able to understand the basic concepts hidden behind this technology.

By design, a blockchain data can not be modified. This is because once the data is recorded in any given block it cannot be altered without alteration of all the subsequent blocks connected with each other.

Beginner Guide to Blockchain: Core Elements of Blockchain

Blockchain consists of datasets which are composed of a chain of data packages (blocks) where a block comprises multiple transactions (Fig.1). Starting with the First Block known as Genesis Block.

Example of blockchain, Guide to Blockchain

The blockchain is extended by each additional block and hence represents a complete ledger of the transaction history which prevents fraud transactions and double spending of the currency. Blocks can be validated by the network using cryptographic means. Each block contains the following elements 

  1. Hash Value
  2. Timestamp
  3. Transactions 
  4. Nonce
  5. Data

Beginner Guide to Blockchain: HASH VALUE

It is an algorithm that converts data of variable size (“message”) to a binary array of a fixed size (“hash value”, “hash”, or “message digest”). It is a one-way function, that is, a function which is practically infeasible to invert.

Properties of Hash

Hash has a fixed length.
Same data always maps to the same hash.
Different data always maps to a different hash (within practical limitations).
It is infeasible to convert hash to data.
A small change in data leads to a large change in hash.
Blockchain, having three zeros at the beginning of the hash is the requirement for a valid hash. The number of leading zeros required is the difficulty.

Hash values are unique having the address of the previous block also known as parent block. The first block of a blockchain is called genesis block which has no parent block. 

Hashes are of a fixed length since it makes it nearly impossible to guess the length of the hash if someone was trying to crack the blockchain.

How to Calculate Block Hash

A hashing function takes data as input, and returns a unique hash.

f ( data ) = hash

Hash is a “digital fingerprint” of the entire block, the data is the combination of index, timestamp, previous hash, block data, and nonce.

f ( index + previous hash + timestamp + data + nonce ) = hash

Guide to Blockchain: Genesis Block in Blockchain

Calculating the hash function of the above mentioned genesis block, 

f ( 0 + “0” + 1612879440000 + “Welcome to Blockchainblogging.com ” + 1138 ) = 000b7a5c8f4e017c09173141b331ae6a39a13a32ce4f3a6b8b94f5b187660e42

List of few Cryptographic Hash Algorithms

  1. MD5
  2. SHA-1 , SHA-2 , SHA-3
  3. RIPEMD-160
  4. Whirlpool (cryptography)
  5. BLAKE, BLAKE2, BLAKE3

Beginner Guide to Blockchain: TIMESTAMP

A timestamp is an encoded information or sequence of characters identifying when a certain event occurred, usually specifying date and time.In recent times usage of the term has reference to the information of date and time in digital format attached to digital data. 

Hashed Digital data can be incorporated into a transaction stored in the blockchain, which serves as evidence of the time at which that data existed.

Tampering with the timestamp would require more computational resources than the rest of the network combined, and cannot be done unnoticed in an actively defended blockchain.

The Blockchain Timestamp value is in the form of a Unix Timestamp. Unix Timestamp is the number of seconds that have elapsed since 01.01.1970 meaning 0000000000 in UNIX time is equal to January 1, 1970 12:00:00 AM.  A timestamp is the converted value of GMT.

Thus, if a block is created, it will take current time of GMT and convert it into Unix Time, validate it if it is greater than the saved time of the previous block and then save it. You can convert any time to UNIX time on https://www.epochconverter.com/.

Beginner Guide to Blockchain: NONCE 

Number Only Used Once (Nonce). The nonce is the number used to find a valid hash. It is often a random number issued in an authentication protocol to ensure that same communication is not reused.To find a valid hash, we need to find a nonce value that will produce a valid hash when used with the rest of the information from that block.

The process of determining this nonce is called mining using Consensus Mechanism. Miners test and discard millions of Nonce per second until they find that Golden Nonce which is valid. In order to complete the verification faster than other miners, miners compete with each other using their computer hashing power. Once the Golden Nonce is found, they can complete the Block and add it to the Blockchain and thereby receive the Block reward. We start with a nonce of 0 and keep incrementing it by 1 until we find a valid hash. As difficulty increases, the number of possible valid hashes decreases. With fewer possible valid hashes, it takes more processing power to find a valid hash.

Guide to Blockchain: Block connected in Blockchain

Genesis Block Nonce: 1138 ; Block #1 Nonce: 314

Beginner Guide to Blockchain: TRANSACTIONS

Transaction data consists of Transaction Date and Time, Sender Address, Receiver Address, and the Transaction Amount. Each transaction on a blockchain has its own unique transaction ID. For most blockchains, an ID is a 64-character code that takes up 256 bits (or 32 bytes) of memory.

Merkle Tree for storing Blockchain Transactions

Merkle Trees take an enormous number of transaction IDs and run them through a mathematical process that results in one 64-character code, which is called a Merkle Root. 

The Merkle Root is vital because it authorizes any computer to quickly verify that a specific transaction took place on a certain block as accurately as possible. Its architecture helps to speed up security authentication in big data applications. It is a complete binary tree, and each node is to hash the value from its child node.

Guide to Blockchain: Merkle Root for four transactions

For Example, there are four transactions Transaction A, Transaction B, Transaction C, and Transaction D till now so Hash function of all transactions are grouped together in binary tree format to give combined hash of A,B,C and D: H(H(H(A)|H(B))|H(H(C)|H(D)))) as a Merkle Root.  

Guide to Blockchain: Merkle Tree in Blockchain Block

Merkle tree allows every node on the network to verify individual transactions without having to download and validate the entire block. Even a bit of incorrect data would lead to vastly different Merkle roots because of the properties of the hash.

Beginner Guide to Blockchain: References

https://medium.com/@kschmeisser55/summary-14-what-does-a-blockchain-block-look-like-c0e1807e9a84

https://www.tutorialspoint.com/what-is-a-nonce-in-block-chain

Reference: Article of An Image Authentication Scheme Using Merkle Tree Mechanisms Yi-Cheng Chen , Yueh-Peng Chou and Yung-Chen Chou

Leave a Reply

*

X
wpChatIcon