A block in a blockchain is a container data structure that contains a series of transactions. Utilizing the concept of cryptography, let us understand how a block in a blockchain secures data.
A block contains multiple digitally signed and encrypted transactions, which are already verified by the peers. Cryptographic security or digitally signed transactions ensure that people can only view information on the ledger that they are authorized to see.
For instance, in Bitcoin – On an average, a block may contain more than 500 transactions. The regular size of a block is around 1MB. Satoshi Nakamoto proposed the upper bound of 1MB in 2010.
As of March 2018, reports suggested that this size might go up to 8MB or higher. Larger blocks can help process a higher number of transactions in one go.
A block consists of two components:
- Block Header
- List of Transactions
Blockchain is a sequence of blocks connected together by the hash of previous block. Hash functions construct a chain type of structure.
Metadata about a block:
- Previous block hash, used to construct the current block hash.
- Mining statistics, used to construct the block.
- Merkle tree root, stores the information or a hash value of all the transactions.
- Previous Block Hash
Every block inherits from its previous block, i.e., we use previous blocks’ hash to create the new blocks’ hash, which makes the blockchain tamper-proof. This means, if we want to make any changes in a specific block, we will have to change the particular hash value. This difference will lead to a change in all the block values.
Therefore, in a distributed network, if any individual tampers with a block, they are required to make changes in all the previous blocks. However, it is highly impossible as the algorithm is dexterously complicated and time-consuming, with miners adding a new block every moment, continually changing the entire chain of data.
- Mining Statistics
The header contains the mining statistics – timestamp, nonce and difficulty. In Bitcoin mining, the hash function is :
Hk = Hash (Hk-1 || T || Nonce)
where, Hk-1 is the previous hash, T is the set of transactions, nonce as in random nonce value.
The task of a miner is to find out the nonce value, such that he can ensure certain difficulty on the generated hash value (Hk).
The complexity in Bitcoin is, every time the hash value Hk is generated , we have to find out the nonce. So whatever is the value of each k, it will have 20 numbers of 0’s in its prefix, or the first 20 bits will be 0’s.
Now, by the property of the hash function, even if each k is known, we will not be able to find out the message, but if the message is identified, we will be able to find out each k. Miner has to change the nonce, try with different values of the nonce to find out when the objective is achieved. The purpose is that the generated hash value will have some certain no. of 0’s in the beginning. This is termed as complexity – no. of 0’s at prefix.
The complexity of the mining algorithm will tell us how many number of 0’s are in the beginning. As we increase the complexity of algorithm, we will require more time to find the nonce value.
The blockchain header contains three parameters:
- Timestamp -> When that mining has been done
- Nonce value -> Providing the corresponding hash value
- Difficulty -> Complexity of algorithm – determines how difficult was it to find out that particular nonce to meet the criteria of the complexity of having certain number of 0’s at the prefix of hash value.