What are public and private keys? How are they used in Ethereum?

Maurice Smith
Maurice Smith
Researcher specializing in Ethereum DeFi; 专注于以太坊DeFi的研究员。

Public and Private Keys: Your "Bank Account Number" and "Password" in the Ethereum World

Hey there! Glad to see you're interested in public and private keys – these are the most fundamental and core concepts for entering the crypto world. Don't be intimidated by the terminology; they're actually much simpler than they sound. Let's use a real-life analogy to make sure you understand immediately.

Imagine your bank account:

  • You have a bank account number that others can use to send you money. It's perfectly safe to tell anyone your account number.
  • You have a bank card PIN (or payment password) that only you know. You need to enter it when withdrawing or transferring money to prove to the bank, "It's me making this transaction." You must never tell this password to anyone.

In the world of Ethereum (and almost all cryptocurrencies), public and private keys play similar roles.


1. Private Key – Your "Bank Card PIN"

A private key, as the name suggests, is a private, secret key.

  • What is it? Essentially, it's a long string of characters (usually a 64-character hexadecimal number) randomly generated through cryptographic algorithms. You can think of it as a super, super complex password.
  • What does it do? It has one crucial function: to "sign" transactions, proving your ownership of the account's assets. When you want to send ETH or any tokens from your Ethereum address, your wallet software uses your private key to sign this transaction (much like signing a contract). This signature is unique and proves to the entire network that "I indeed authorized this expenditure."
  • Importance? Absolutely confidential! This is the highest level of access to your account. Whoever possesses your private key controls all assets in your account and can do anything with them. Unlike a bank password, which can be reset if forgotten, if a private key is lost, it's gone forever; if it's leaked, your assets are effectively given away to someone else.

Remember: Your private key is the sole proof of ownership of your crypto assets. What we commonly refer to as a Mnemonic Phrase (or seed phrase, usually 12 or 24 English words) is simply another format designed to help you remember and back up your private key.


2. Public Key – The "Bank Account Number" Generated from Your "Password"

A public key, on the other hand, is a public key.

  • What is it? It's derived from your private key using a one-way cryptographic algorithm. It's also a long string of characters.
  • What does 'one-way' mean? It means that while you can easily calculate a public key from a private key, it's absolutely impossible to derive your private key from your public key in reverse. This is like being able to make a cake from eggs, but not being able to turn a cake back into eggs. This property ensures you can safely share your public key (or the address derived from it) with others.
  • What does it do? The primary function of a public key is to verify signatures. When nodes (miners) on the network receive a transaction you've signed, they use your public key to verify if the signature is valid. If the verification passes, it confirms that the transaction was indeed signed by the private key paired with that public key, ensuring its authenticity.

3. Ethereum Address – A More Concise and Commonly Used "Receive Code"

You might notice that in daily use, what you share with others to receive funds isn't your public key, but a shorter string starting with 0x. This is your Ethereum address.

  • What's its relationship with the public key? An Ethereum address is derived from the public key after another series of calculations and compression. You can think of it as a "shortened version" or "nickname" for the public key, making it more convenient to use and share.

So, their generation relationship is a one-way chain like this:

Private Key -> Public Key -> Ethereum Address

This process is also irreversible.


How Do They Work Together in Ethereum? – Behind a Transaction

Let's walk through the full process of you sending 1 ETH to a friend on Ethereum:

  1. Create Transaction: You input your friend's Ethereum address and the transfer amount (1 ETH) into your wallet. This is like filling out a "transfer request form."
  2. Sign Transaction: You click "Confirm" or "Send." At this point, your wallet software will use your private key in the background to cryptographically sign the content of this "transfer request form," stamping it with a unique "private seal."
  3. Broadcast Transaction: Your wallet sends this signed "transfer request form" (i.e., the signed transaction data) to the entire Ethereum network.
  4. Network Verification: All nodes on the network receive this transaction. They will:
    • See that the transaction originated from your address.
    • Use your public key (which can be derived from the transaction signature) to verify if your "private seal" (signature) is authentic.
    • Once verified, nodes confirm the transaction is legitimate and valid, and then package it into a new block, recording it on the blockchain.
  5. Transaction Completed: Once the transaction is included in a block, your friend's address balance will increase by 1 ETH, and your address balance will decrease by 1 ETH.

Throughout this process, your private key never leaves your device; it's only used locally for signing. What you broadcast is public information with a signature, which anyone can use your public key to verify, but no one can forge your signature.


Quick Summary

NameAnalogyCharacteristicsCan you share it with others?
Private KeyBank card PIN / Safe deposit box master keyAbsolutely confidential, used for signing and authorizationAbsolutely NOT!
Public KeyFull bank account number (less commonly used)One-way derived from private key, used to verify signaturesYes
Ethereum AddressReceive QR code / Simplified bank account numberOne-way derived from public key, used to receive assetsOf course, yes!

Hope this explanation helps you fully understand! In the crypto world, self-custody of your private key is the most important thing.

Remember the most crucial principle: Private key in hand, you own the world; private key lost, you own nothing. Have fun exploring the Ethereum world!