Sha-256
Last updated
Last updated
👉SHA-256 is one of the first and most used hashing algorithms in blockchains like Bitcoin, Bitcoin Cash, and Bitcoin SV. It moderates the creation and management of addresses, and is also used for transaction verification. Bitcoin uses double SHA-256, meaning that it applies the hash functions twice.
It’s used in various stages in a blockchain, most commonly in:
👉Consensus mechanism: Here the miners calculate the hash of new blocks to be created using the algorithm by varying the value of nonce in a bitcoin block until they reach the hash below the threshold. The 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 the signature to validate the transaction
👉Collision resistant: No two input values can produce the same hash output. This ensures that every block in the blockchain ledger is assigned a unique hash value
👉Preimage resistance: The input can’t be recreated given a hash value. This ensures that during the proof of work in bitcoin, the miners cannot guess the value of nonce by converting the acceptable hash back into input. Instead, they have to use the brute force method, which ensures that the work is done.
👉Deterministic: The hash function’s output should always remain the same, given that the input remains the same. This is a basic property of digital signatures, as the computed hash against a given input should remain consistent when calculated by the receiver and sender.
👉Large output: The 256-bit output adds up to 2^256 possibilities making it impossible to apply the brute force solution to crack the hash
👉Avalanche effect: If there is a small change in the input, the output changes dramatically. This makes sure that the hash value can’t be guessed based on the input values. This makes the hash more secure.
Due to the complexity of the modern computers, some of the hashing algorithms have already been broken down
SHA-256 - Bullet properties👉Length of the original message should be less than 2^64 bits👉2^256 number of possibilities👉It’s like fingerprint👉The output will always will be the same length no matter the size of the input👉256-bit output length👉Still considered secure - no exploitable vulnerabilities👉Relatively fastReal world use cases outside blockchain technology👉Anti-virus softwares👉word.exe + FP -> downloading the fingerprint with the file👉Token = sha256(username + key); (JWT MAC HMAC)