Hashing & Encryption : The Difference and Usage in Blockchain
🤔 Earlier it was said that hashing is a one-way street. If so, how is something encrypted decrypted? If it is encrypted using a public key and decrypted with a private key, does this mean the sender gives their private key to the receiver?
No. The Private Key is never given to anyone! Giving that away is like handing the key of your vault to a thief.
If you thought this, you are mixing up the two distinct contexts where Hashing and Encryption are applied. Let's understand this clearly.
Untangling the Confusion (Hashing vs Encryption)
These are two distinct technologies. Both are used in a blockchain, but for two different tasks:
- Hashing (SHA-256): This is the one-way street mentioned earlier. This is used not to hide a message, but to confirm that the message has not been tampered with (Integrity).
- Asymmetric Encryption: This is a two-way street. This is used to conceal a message (Privacy) and allow only the intended recipient to read it.
How to Decrypt Without Giving Away the Private Key?
This is where the magic of the Public/Private Key occurs. The sender never gives their Private Key to the recipient.
Imagine you (Sender) want to send a secret message to me (Receiver):
- Me (Receiver): I make my Public Key visible to the entire world. It is simply like an open padlock. However, its key (the Private Key) is kept solely with me.
- You (Sender): You take my Public Key (open lock) and encrypt (lock) your message with it. Now no one can read that message.
- The Intermediary: As this locked message travels over the internet, anyone can see it. But no one possesses the key to unlock it.
- Me (Receiver): When I receive the message, I insert my Private Key—which exists only with me—and Decrypt it.
Even you who sent the message cannot reopen it once locked, because you do not have my Private Key (the key to my padlock)!
Why is this Important to Blockchain?
Most data on a blockchain is Hashed (one-way) because those records need to be transparent to the whole world (Transparency). But to prove that you are the rightful owner of those funds, you use the Digital Signature created with your Private Key.
Is it clear now? The Private Key is never shared with anyone. You lock with my Public Key (lock), and I unlock with my Private Key.
"The Key Difference: Hashing for Integrity, Encryption for Privacy.
A common point of confusion for many is the distinction between Hashing and Encryption. Hashing is like taking a fingerprint of data, which cannot be reversed (One-way). This is utilized to prevent data tampering. In contrast, Encryption is a method where data is locked and can subsequently be reopened (Two-way) using the corresponding key (Private Key). The security of a blockchain network is secured through the harmonious integration of both technologies."
🤔 You might now be wondering: "Then where does SHA-256 fit into this sender/receiver story?"
If this question occurred to you, you are someone reading this article with keen comprehension. This is precisely where many people confuse these two technologies. I will explain this very simply using the analogy of an envelope.
When you (Sender) send Bitcoin to me (Receiver), both SHA-256 and Public/Private Keys work simultaneously.
Let's see where these two are used in a blockchain:
SHA-256 is Used for Sealing (Sealing the Box)
SHA-256 applies to protecting transaction data. The message stating you are sending 10 BTC to me is hashed through SHA-256 to create a "digital fingerprint." This is done so that if anyone alters the numbers or data en route, it will be detected. The role of SHA-256 is verifying the "Integrity" (correctness) of the transaction.
Public/Private Keys are Used to Confirm Ownership (Ownership & Access)
This is where you actually transfer BTC to me:
You (Sender) use your Private Key to place a "signature" (Digital Signature) onto the Hash generated by SHA-256. This proves to the world that it is genuinely you sending the money.
My (Receiver's) Public Key (Wallet Address) is what you designate as the "intended recipient of the funds."
Later on, I use my Private Key to spend those funds.
Think of sending me a letter:
- You write the letter and stamp a SHA-256 seal on it (confirming the letter hasn't been tampered with).
- You place your Digital Signature over that seal (proving you personally sent the letter).
- You address that letter to my Address (my Public Key).
- I use my key (Private Key) to open that letter and take possession of the funds.
SHA-256 is not the "method" of sending money; it is the security seal applied so that the "details" of the money being sent cannot be altered.
Keys are the tools that determine who the "owner" of those funds is.
"The Duo: How Hashing and Keys Protect Your Bitcoin.
A Bitcoin transaction is secured by the union of two technologies. SHA-256 Hashing prevents alteration of transaction details (Integrity), while Asymmetric Cryptography (Public/Private Keys) confirms the ownership and authenticity of that transaction (Authentication). Because of this, assets can be exchanged with utmost trustworthiness within the Bitcoin network even without an intermediary."
Comments
Post a Comment