Practical Cryptography for Developers
  • Welcome
  • Preface
  • Cryptography - Overview
  • Hash Functions
    • Crypto Hashes and Collisions
    • Hash Functions: Applications
    • Secure Hash Algorithms
    • Hash Functions - Examples
    • Exercises: Calculate Hashes
    • Proof-of-Work Hash Functions
  • MAC and Key Derivation
    • HMAC and Key Derivation
    • HMAC Calculation - Examples
    • Exercises: Calculate HMAC
    • KDF: Deriving Key from Password
    • PBKDF2
    • Modern Key Derivation Functions
    • Scrypt
    • Bcrypt
    • Linux crypt()
    • Argon2
    • Secure Password Storage
    • Exercises: Password Encryption
  • Secure Random Generators
    • Pseudo-Random Numbers - Examples
    • Secure Random Generators (CSPRNG)
    • Exercises: Pseudo-Random Generator
  • Key Exchange and DHKE
    • Diffie–Hellman Key Exchange
    • DHKE - Examples
    • Exercises: DHKE Key Exchange
  • Encryption: Symmetric and Asymmetric
  • Symmetric Key Ciphers
    • Cipher Block Modes
    • Popular Symmetric Algorithms
    • The AES Cipher - Concepts
    • AES Encrypt / Decrypt - Examples
    • Ethereum Wallet Encryption
    • Exercises: AES Encrypt / Decrypt
    • ChaCha20-Poly1305
    • Exercises: ChaCha20-Poly1305
  • Asymmetric Key Ciphers
    • The RSA Cryptosystem - Concepts
    • RSA Encrypt / Decrypt - Examples
    • Exercises: RSA Encrypt / Decrypt
    • Elliptic Curve Cryptography (ECC)
    • ECDH Key Exchange
    • ECDH Key Exchange - Examples
    • Exercises: ECDH Key Exchange
    • ECC Encryption / Decryption
    • ECIES Hybrid Encryption Scheme
    • ECIES Encryption - Example
    • Exercises: ECIES Encrypt / Decrypt
  • Digital Signatures
    • RSA Signatures
    • RSA: Sign / Verify - Examples
    • Exercises: RSA Sign and Verify
    • ECDSA: Elliptic Curve Signatures
    • ECDSA: Sign / Verify - Examples
    • Exercises: ECDSA Sign and Verify
    • EdDSA and Ed25519
    • EdDSA: Sign / Verify - Examples
    • Exercises: EdDSA Sign and Verify
  • Quantum-Safe Cryptography
    • Quantum-Safe Signatures - Example
    • Quantum-Safe Key Exchange - Example
    • Quantum-Safe Asymmetric Encryption - Example
  • More Cryptographic Concepts
    • Digital Certificates - Example
    • TLS - Example
    • One-Time Passwords (OTP) - Example
  • Crypto Libraries for Developers
    • JavaScript Crypto Libraries
    • Python Crypto Libraries
    • C# Crypto Libraries
    • Java Crypto Libraries
  • Conclusion
Powered by GitBook
On this page
  • ETHash
  • Equihash
  • More about ASIC-Resistant Hash Functions

Was this helpful?

  1. Hash Functions

Proof-of-Work Hash Functions

PreviousExercises: Calculate HashesNextMAC and Key Derivation

Last updated 5 years ago

Was this helpful?

Blockchain proof-of-work mining algorithms use a special class of hash functions which are computational-intensive and memory-intensive. These hash functions are designed to consume a lot of computational resources and a lot of memory and to be very hard to be implemented in a hardware devices (such as integrated circuits or miners). Such hash functions are known as "ASIC-resistant".

Many hash functions are designed for proof-of-work mining algorithms, e.g. ETHash, Equihash, CryptoNight and Cookoo Cycle. These hash functions are slow to calculate, and usually use GPU hardware ( of graphics cards like NVIDIA GTX 1080) or powerful CPU hardware (like Intel Core i7-8700K) and a lot of fast RAM memory (like DDR4 chips). The goal of these mining algorithms is to minimize the centralization of mining by stimulating the small miners (home users and small mining farms) and limit the power of big players in the mining industry (who can afford to build giant mining facilities and data centers). A big number of small players means better decentralization than a small number of big players.

The main weapon in the hands of the big mining corporations is considered the , so the design of modern cryptocurrencies and usually includes proof-of-work mining using an ASIC-resistant hashing algorithm or proof-of-stake consensus protocol.

ETHash

Let's explain in brief the idea behind the ETHash proof-of-work mining hash function used in the Ethereum blockchain.

  • ETHash is the proof-of-work hash function in the Ethereum blockchain. It is memory-intensive hash-function (requires a lot of RAM to be calculated fast), so it is believed to be ASIC-resistant.

How does ETHash work?

  • A "seed" is computed for each block (based on the entire chain until the current block).

  • From the seed, a 16 MB pseudorandom cache is computed.

  • From the cache, a 1 GB dataset is extracted to be used in mining.

  • Mining involves hashing together random slices of the dataset.

Learn more about ETHash at: , .

Equihash

Let's explain in briefly the idea behind the Equihash proof-of-work mining hash function used in Zcash, Bitcoin Gold and a few other blockchains.

  • Equihash is the proof-of-work hash function in the Zcash and Bitcoin Gold blockchains. It is memory-intensive hash-function (requires a lot of RAM for fast calculation), so it is believed to be ASIC-resistant.

How does Equihash work?

  • Uses BLAKE2b to compute 50 MB hash dataset from the previous blocks in the blockchain (until the current block).

  • Solves the "Generalized Birthday Problem" over the generated hash dataset (pick 512 different strings from 2097152, such that the binary XOR of them is zero). The best known solution (Wagner's algorithm) runs in exponential time, so it requires a lot of memory-intensive and computing-intensive calculations.

  • Double SHA256 the solution to compute the final hash.

More about ASIC-Resistant Hash Functions

Learn more about Equihash at: , .

Lear more about the ASIC-resistant hash functions at: .

FPGA
ASIC
rigs
ASIC miners
https://github.com/ethereum/wiki/wiki/Ethash
https://github.com/lukovkin/ethash
https://www.cryptolux.org/images/b/b9/Equihash.pdf
https://github.com/tromp/equihash
https://github.com/ifdefelse/ProgPOW