1.4 Cryptography
Last updated
Last updated
Cryptography is fundamental to blockchain technology, providing security, integrity, and privacy in a trustless environment. It ensures that transactions are secure and tamper-proof while enabling participants to maintain anonymity.
Hashing
A hash function transforms input data into a fixed-size output (hash).
Properties:
Deterministic: The same input always produces the same hash.
Irreversible: Impossible to derive the original input from the hash.
Collision-Resistant: Two different inputs should not produce the same hash.
Use Cases:
Linking blocks in the blockchain (e.g., SHA-256 in Bitcoin).
Verifying data integrity.
Public-Key Cryptography (Asymmetric Cryptography)
Mechanism: Involves two keys:
Public Key: Shared with others to receive messages.
Private Key: Kept secret and used to sign or decrypt messages.
Use Cases:
Digital signatures to verify transaction authenticity.
Generating wallet addresses.
Digital Signatures
Mechanism:
A private key signs the transaction, creating a unique digital signature.
The public key verifies the signatureβs validity.
Use Cases:
Ensures the sender is authorized to spend funds.
Prevents tampering with transaction data.
Elliptic Curve Cryptography (ECC)
A lightweight cryptographic technique used in blockchain to generate public and private keys.
Advantages:
High security with smaller key sizes compared to RSA.
Efficient for resource-constrained devices.
Merkle Trees
A hierarchical data structure that summarizes all transactions in a block.
Properties:
Efficient verification of large datasets.
Any tampering in the transaction data invalidates the root hash.
Use Cases:
Block validation.
Ensuring data integrity.
Zero-Knowledge Proofs (ZKPs)
A cryptographic method where one party proves to another that they know a value without revealing the value itself.
Use Cases:
Enhancing privacy in blockchain (e.g., ZCash).
Secure authentication.