What is SHA-256?
A secure hashing algorithm or commonly referred to as SHA-256, is an unkeyed cryptographic hashing functionUnkeyed cryptographic hash functions are the ones which generate the hash output with just the input data as the only parameter. that takes an input of variable length and produces a 256-bit long hash output.
Uses of SHA-256 in blockchain
SHA-256 is one of the first and most prominently used hashing algorithms in blockchains like Bitcoin, Bitcoin Cash, and Bitcoin SV. SHA-256 is used in various stages in a blockchain, most prominently:
- Consensus mechanism: Miners calculate the hash of new blocks to be created using SHA-256 by varying the value of nonce in a bitcoin block until they reach the hash below the threshold. Then that block can be accepted into the ledger.
- Chains of blocks: Each block in the ledger contains a hash generated by SHA-256 referring to the preceding block in the chain.
- Digital signatures: Transactions use digital signatures to maintain integrity, the information used in the transaction is hashed using SHA-256, and then it is encrypted with the sender's private key to generate a signature. The miner then verifies this signature to validate the transaction.