In [[Public Key Cryptography]], a hashing algorithm is a mathematical function that takes in an input (a message, data, or financial transaction) and produces a fixed-size output, known as a [[Bitcoin Anatomy#^ec6e27|hash value]]. The hash value is unique to the input data, meaning that any change to the input data will result in a different hash value. While "hashing function" refers more generally to the concept of transforming data into fixed-size digests with certain properties like determinism and collision resistance; "hashing algorithm" specifically denotes an actual implementation or technique used for computing those hashes.
Purpose of Hashing Algorithms in Blockchains:
1. Data Integrity: Any change made to the original data will result in a completely different hash value, alerting network participants to potential tampering attempts.
2. Immutability: By using cryptographic hash functions, each block's header includes the hash value of the previous block's header as part of its own calculation. This creates an unbreakable chain where modifying one block would require recalculating all subsequent hashes, which is a computationally expensive task that makes altering historical records practically impossible.
3. Security: Cryptographic hash functions ensure secure transactions by providing digital signatures and verifying authenticity through public-key cryptography mechanisms like Merkle trees or Patricia trees.
Hashing algorithms are used in public key cryptography to create digital signatures, which are used to verify the authenticity and integrity of digital documents and transactions. Hashing algorithms are used to verify the transaction blocks that make up the blockchain. Each block contains a [[Bitcoin Anatomy#Hash|hash value]] of the previous block, bolstering the property of [[Censorship resistance|censorship resistance]].
Here is a table of the hashing algorithms used by some of the most popular blockchains:
| Blockchain | Hashing Algorithm/Function | Industry Standards/Certifications |
| ---------- | -------------------------- | -------------------------------------- |
| Bitcoin | SHA-256 | FIPS 180-4 |
| Ethereum | Ethash/Keccak-256(SHA3) | N/A |
| Litecoin | Scrypt | NIST SP800-131A |
| Cardano | Blake2b | Recognition: NIST SP 800-185; RFC 7693 |
FIPS is the Federal Information Processing Standards are a set of guidelines developed by the US government for use in computer systems that handle sensitive information. NIST is the National Institute of Standards and Technology; it is a US government agency responsible for developing technology standards and guidelines.
A quick look at some hashing algorithms and their history:
1. SHA-256: This algorithm was developed by the National Security Agency (NSA) in 2001 and is widely used in many blockchain networks including Bitcoin. It produces a 256-bit hash value that is unique for every input data. The benefits of using this algorithm include high security, fast processing speed, and low computational requirements.
2. Ethash: This hashing algorithm was specifically designed for Ethereum network to prevent ASIC mining which can lead to centralization of mining power. It uses a combination of Keccak hash function with Dagger-Hashimoto memory-hard proof-of-work protocol which makes it difficult for ASICs to mine on the network while allowing GPU miners to participate effectively.
3. Keccak-256(SHA3): Developed in 2008 by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche as part of the SHA-3 competition held by NIST. While previously used for mining on Ethereum's blockchain, it now plays an important role in ensuring security within its Proof of Stake consensus mechanism through block validation.
4. Scrypt: Developed by Colin Percival in 2009 as an alternative to SHA-256, Scrypt is used by Litecoin among other cryptocurrencies. It requires more memory than SHA-256 making it less susceptible to brute-force attacks from ASICs but also slower than SHA-256.
5. CryptoNight: Developed by the Bytecoin team in 2013, it is used by several privacy-focused cryptocurrencies such as Monero. It is designed to be ASIC-resistant, making it more accessible for CPU and GPU miners. Uses ring signatures and stealth addresses to enhance privacy
6. Equihash: Developed by Alex Biryukov and Dmitry Khovratovich in 2016, it is used by several cryptocurrencies including Zcash, Komodo, Bitcoin Gold, and Horizen (formerly ZenCash). Based on the Generalized Birthday Problem which makes it difficult for ASICs to mine on the network while allowing GPUs to participate effectively. Provides enhanced security through its use of zero-knowledge proofs (zk-SNARKs).
7. Blake2b: Developed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn, and Christian Winnerlein, it is an improved version of the original Blake algorithm which won the NIST hash function competition in 2012. Blake2b has been recognized by industry standards such as NIST SP 800-185 and RFC 7693 for its high security and fast processing speeds on 64-bit platforms.
>[!example]
In Ethereum's PoS system, validators are chosen based on their stake in the network and are responsible for proposing or validating blocks. When a validator proposes a block, they must include a hash value that is generated using the Keccak-256 algorithm. This hash value serves as proof that the validator has performed computations to create the block and to validate all transactions within it.