Once you know what is blockchain technology, you understand that the sealing mechanism is the key to the successful and accurate maintenance of a blockchain. But how can these stringent requirements be fulfilled?
The conditions imposed on the sealing mechanism of a blockchain are satisfied using a hash function.
Learn Online Software Development Courses from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.
The mathematical definition of a hash function is a function that takes a variable length numerical input and returns a number of fixed length as output. In order to work with strings of characters, ASCII codes can be used to convert characters into integers and vice versa. The output returned by the hash function is known as the hash value. Most popular hash functions have a fixed hash value size lying between 160 and 512 bits.
All blockchains impose target conditions on the output of the hash function when a block is an input to it. To fulfil these target conditions, a seal is computed and concatenated to the block being stored. This seal encrypts the contents of the block and preserves their integrity. This is because any change to the block would drastically change its corresponding hash value, and cause it to escape the target conditions. The computed seal is commonly known as a nonce. A common target condition that the nonce must satisfy is ensuring that the leading ‘n’ characters of the output hash be zero. The value of ‘n’ sets the level of difficulty in the blockchain, which may be adjusted periodically as per the requirements of the network.
There are three important properties that hash functions must satisfy in order to be used effectively in the blockchain. Given the hash value output by the function, it must be computationally difficult to find any input that, when hashed, returns the given output. This is known as pre-image resistance. In other words, the hash function should be computationally expensive to reverse. Similarly, given the input to the function, it must be difficult to compute any other input to the same function that outputs the same hash value as the original input. This is known as collision resistance. However, given any input to the hash function, it should be easy to compute the corresponding value output by the hash function. This is to ensure easy verification of the integrity of the contents of the blockchain.
The first two properties given above are critical because they slow down the rate of computation of the nonce, or proof of work. This causes the rate at which blocks are added to the chain to be limited by the rate of computation of the nonce, and not the rate at which transactions occur. This is absolutely crucial because it prevents dishonest individuals in the network from generating and adding blocks of false transactions to the chain at a quicker rate than the network itself. This is because a single individual cannot compete with the computing power of a large network, and thus the longest chain of blocks always belongs to the majority in the network itself.
This allows us to be able to safely accept the longest chain as the real blockchain under the assumption that the majority in the network is honest. The vulnerabilities of a blockchain in the case of a dishonest majority have already been discussed in a prior article.
There are many different forms of hash functions that are used in cryptography. MD5 is the most popular hash function of the Message Digest family, which also consists of MD2, MD4 and MD6. The SHA family, consisting of SHA-0, SHA-1, SHA-2 and SHA-3, is another popular set of algorithms used for hashing. RIPEMD and Whirlpool are other common hash functions. These functions all implement different techniques to obtain the properties of pre-image and collision resistance.
The sealing mechanism of the blockchain ensures that transactions cannot be falsified after the blocks have been added to the chain. But how are any imposters in the network prevented from faking a transaction between two members of the network? In other words, how can the identity of the members involved in the transaction be verified in an anonymous network distributed across the globe?
Verification of any transaction conducted in a blockchain network requires a digital signature.
Each member of the blockchain network is assigned a public key and a private key. The public key of each member is known to all members of the network, but the private key remains secret and is known only to the individual it is assigned to. Any message encrypted using the private key of a member node can only be decrypted using the corresponding public key of the pair, and vice versa. This allows nodes to approve transactions by signing them with their private key. This can now only be decrypted by their corresponding public key, thus verifying them as the senders. The transaction can similarly be encrypted by the receiver as well in order to confirm their involvement in the transaction.
This mechanism allows nodes to authenticate transactions by verifying the identities of the nodes involved while still maintaining their anonymity. The digital signature and the concept of public and private keys prevents other nodes from making false transactions on your behalf even in the event of a 51% attack. Thus, it is an elegant way of ensuring the security as well as the anonymity of individual members of the network.
If you are interested to create blockchain applications from scratch, check out upGrad & IIIT-B’s Executive Certification in Blockchain from IIITB.