
Hashing is the process of converting data into a fixed size of text. For example, this newsletter of 500 words can be converted into a string like - sh4u2dn12sj3n4.
This is done with the help of a mathematical function, also known as Hash Function and the output string (sh4u2dn12sj3n4) is called Hash value. Hashing is used to prevent fraud transactions in a blockchain.
As you may recall, Blockchain is a shared register maintained by a network of computers.
Blockchain stores information in a data structure called ‘block’, which does not allow any changes or deletion in the stored information. A block also comes with limited storage space, post which it is sealed and added to a chain of other filled blocks.
In Blockchain, hash value is used to denote the state of the blockchain. Each transaction carries information like amount being sent, sender & reciever address, and timestamp.
This information is put through the Hash function to generate a hash value called transaction id. This transaction id can be used to identify and confirm that a transaction has occured.
The first block in blockchain contains a fixed number of transactions, which are combined to create a hash value. When a new block is added to the chain, the hash value of first block and the new set of transactions become the input value for our hash function and a new hash value is generated for the second block.
This process is repeated for every new block that is added to the chain, making the blockchain immutable. Because, even a small change in the transactions or the sequence of transactions will change the block’s respective hash value. A change that will be detectable by the other people in the network.
Further, the hashing speed of a hash function varies by the algorithm. There can be multiple types of these hash functions or algorithm. Bitcoin blockchain is know to use SHA-256 (Secure Hash Algorithm).
Use of Hash in mining crypto
Mining or the process of validating and processing a transaction on the blockchain is closely connected to hash values. Miners try to guess the input of the hash value, with the help of partially known hash value. This partial value is derived from the current state of blockchain.
Miners try to guess the input that will generate the target hash value in the hash function. This is done by running millions/trillions of guesses per second through the algorithm, and hence, consumes a lot of computational power.
The first miner to guess the input value wins and is rewarded with crypto tokens.
The first miner to guess the input value wins and is rewarded with crypto tokens. Once the input value is known, other miners also validate the transaction and transaction is completed.
How did it all start?
On January 12, 2009, a computer programmer Hal Finney recived the first bitcoin mining reward, 10 bitcoins. He got the tokens from ‘Satoshi Nakamoto’ for mining for block-70. Ever since, it has been speculated that Satoshi Nakamoto created bitcoin network. As you would recall, Satoshi Nakamoto published Bitcoin’s whitepaper back in 2008. Â
I recommend reading B for Blockchain in continuation of this edition. That’s all from H for Hashing. If you recall any other Web3 terms starting from the letter H, please leave a comment and I will include them in later editions.Â
Until next week!
Join Web3 Alphabet on WhatsApp or Discord to get updates on Web3 events, Twitter spaces, and Web3 job openings.
Congrats on 2 months of web3 alphabet, Yatti! Keep going...