bongkow

View My GitHub Profile

Ethereum Signatures Explained in 5 Minutes

Below is a quick, 5-minute read explaining how Ethereum signatures work, broken down into the essential steps and concepts.


1. Private Keys and Public Addresses

Private Key

Public Key & Address


2. The Role of Signatures in Ethereum

A signature in Ethereum proves two things:

  1. Ownership: You own the private key controlling a given address.
  2. Integrity: The data you signed has not been altered.

When you send a transaction or sign a message, your wallet uses your private key to create a digital signature. Anyone can then verify that signature using your public address— without seeing your private key.


3. ECDSA Signatures: How They’re Formed

Ethereum signatures use the Elliptic Curve Digital Signature Algorithm (ECDSA). Here’s a simplified overview of how a transaction or message is signed:

  1. Message Hashing:
    • A transaction or message (the data to be signed) is hashed with the keccak256 algorithm.
    • For human-readable strings, Ethereum’s personal_sign adds a special prefix (“\x19Ethereum Signed Message:\n”) before hashing. This helps prevent replay attacks.
  2. ECDSA Math:
    • The private key signs this hash, resulting in three parameters: R, S, and V.
    • R and S are the core components from the ECDSA process, and V indicates the “recovery id” which helps in recreating the public key for verification.
  3. Signature Output:
    • In Ethereum, the final signature is typically represented as a concatenation of R, S, and V.
    • This signature is sent along with the original data (or transaction).

4. Verifying a Signature

Off-chain Verification

On-chain Verification


5. Common Use Cases

  1. Transaction Signing:
    • Sending Ether or tokens requires signing a transaction with your private key.
    • Once signed, a valid transaction can be broadcast to the network.
  2. Off-chain Messages:
    • You can sign data like a “Login” request to prove you own a particular address—no password needed.
    • This is often done through personal_sign or EIP-712 (structured data).
  3. Smart Contract Interactions:
    • Some smart contracts use signatures to validate actions or “meta-transactions,” allowing gasless or delegated transactions.

6. Bonus: EIP-712 (Typed Structured Data)


In Summary

That’s the essence! With a firm grasp of private keys, hashing, ECDSA, and verification, you now understand how Ethereum signatures secure and power the ecosystem—all in just 5 minutes.