Introduction to cryptography

Why blockchain needs cryptography?

Beginner LevelBy Pratima Sharma

Cryptography in Blockchain

Blockchain is a decentralized ledger where thousands (or even millions) of participants interact without a central authority. Unlike traditional systems such as banks, there’s no middleman to guarantee trust.

So, how do we ensure that:

  • Transactions are authentic?
  • Data inside blocks cannot be tampered with?
  • Users cannot deny their actions?

The answer is cryptography. It is the foundation of trust in blockchain, ensuring security, reliability, and decentralization.

Core Reasons Blockchain Needs Cryptography

1. Data Integrity – Preventing Tampering

  • Every block in a blockchain is linked to the previous block using cryptographic hash functions (e.g., SHA-256 in Bitcoin, Keccak-256 in Ethereum).
  • If someone tries to change even one transaction, the block’s hash changes, breaking the entire chain.

Example:

  • Block A → Hash: 0x1234...
  • Block B stores Block A’s hash (0x1234...).
  • If Block A is altered, its hash becomes 0x9999..., invalidating Block B and all following blocks.

This makes blockchain immutable.

2. Authentication – Proving Ownership

  • Blockchain wallets are based on public/private key cryptography.
  • When you send a transaction, you sign it with your private key.
  • Others verify it with your public key, proving you are the owner.

Real-world analogy: Signing a cheque → Your signature (private key) proves it’s you, and the bank verifies it with your known signature sample (public key).

3. Confidentiality – Protecting Sensitive Data

  • While Bitcoin and Ethereum are transparent, private blockchains (e.g., Hyperledger) require encryption to keep data confidential.
  • Symmetric (AES) or asymmetric encryption ensures that only authorized nodes can access private data.

Example: In a blockchain-based healthcare system, patient medical records must be encrypted so only hospitals/authorized doctors can read them.

4. Non-Repudiation – No Denials Allowed

  • Once a transaction is digitally signed and recorded on the blockchain, the sender cannot deny having made it.
  • Cryptography ensures accountability.

Example: If Alice signs a transaction sending 1 BTC to Bob, her digital signature ensures she cannot later claim, “I never sent it.”

5. Secure Consensus Mechanisms

  • Proof-of-Work (PoW) relies on cryptographic puzzles (hashing).
  • Proof-of-Stake (PoS) relies on digital signatures and key-based validation.
  • Without cryptography, malicious actors could easily cheat the system.

Example: Bitcoin miners solve SHA-256 hash puzzles to add blocks. Without hashing, anyone could add fake blocks.

6. Protecting Against Attacks

Cryptography safeguards blockchain against common threats:

  • Double Spending Attack → Prevented using digital signatures & consensus.
  • Sybil Attack → Public/private key uniqueness prevents fake identities.
  • Data Forgery → Hashing and Merkle trees make forgery detectable.

Real-World Examples of Cryptography in Blockchain

Bitcoin

  • Uses SHA-256 hashing for blocks.
  • Uses ECDSA digital signatures to authorize transactions.
  • Immutability is achieved via hash chaining.

Ethereum

  • Uses Keccak-256 hashing for transactions.
  • Smart contracts rely on digital signatures for execution.
  • Gas fees are tied to cryptographic verification of computations.

Zcash & Monero

  • Use advanced cryptography like Zero-Knowledge Proofs (zk-SNARKs) and Ring Signatures for privacy and anonymity.

Analogy – Blockchain Without Cryptography

Imagine blockchain without cryptography:

  • Anyone could change past transactions (no hashes).
  • Anyone could impersonate you and spend your money (no digital signatures).
  • Data would not be private (no encryption).
  • Miners/validators could cheat consensus easily.

Essentially, blockchain would collapse into a useless, untrustworthy database.

Summary

Here’s how these four properties work in blockchain:

Property Purpose How Blockchain Uses It Example
Confidentiality Keep data secret Encryption, zk-SNARKs, private blockchains Patient records on a healthcare blockchain
Integrity Prevent tampering Hashing, Merkle trees, block hashes Bitcoin block hashes
Authentication Verify identity Public/private key cryptography, digital signatures Ethereum wallet transactions
Non-repudiation Prevent denial of actions Digital signatures + immutable ledger Alice cannot deny sending BTC to Bob

Continue Learning

Explore more topics in Cryptography in Blockchain or browse other tutorials.