The Basics: What Many People Get Wrong
Ethereum Private Key
A standard Ethereum private key looks like this:
fad9c8855b740a0b7ed4c221dbad0f33a83a49cad6b3fe8d5817ac83d38b6a19Key characteristics:
- 256-bit cryptographic key
- 32 bytes (64 hexadecimal characters)
- No "0x" prefix
Ethereum Public Address
Example public address:
0x20F8D42FB0F667F2E53930fed426f225752453b3Key characteristics:
- 160-bit derived value
- 20 bytes (40 hexadecimal characters)
- Typically includes "0x" prefix
Are Public Keys and Ethereum Addresses the Same Thing?
In short: No. An Ethereum address is actually derived from the public key through a specific cryptographic process:
- The public key undergoes Keccak-256 hashing
- The last 160 bits of this hash become the address
- This address is then converted to hexadecimal format
Ethereum Address Case Sensitivity: Does It Matter?
You might notice wallet applications display mixed-case addresses while blockchain explorers accept both uppercase and lowercase. This stems from Ethereum's EIP-55 proposal which introduced checksum validation.
How EIP-55 Works
The JavaScript implementation:
function toChecksumAddress(address) {
address = address.toLowerCase().replace('0x', '')
var hash = createKeccakHash('keccak256').update(address).digest('hex')
var ret = '0x'
for (var i = 0; i < address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += address[i].toUpperCase()
} else {
ret += address[i]
}
}
return ret
}Example addresses:
- Checksum address:
0x7c52e508C07558C287d5A453475954f6a547eC41 - Lowercase address:
0x7c52e508c07558c287d5a453475954f6a547ec41
Benefits of EIP-55
- Backward compatible with existing systems
- Maintains 40-character length
- Provides error detection with 99.9753% accuracy
- More user-friendly than alternatives like ICAP
BIP39 Mnemonic Phrases and Private Keys: The Conversion Process
Most wallets use 12-word mnemonic phrases, though 15, 18, and 24-word variants exist. These phrases enable:
- Easier private key backup and recovery
- Hierarchical deterministic (HD) wallet functionality
- Generation of multiple accounts from single seed
๐ Learn more about HD wallets
From Private Key to Public Key: The Technical Process
Here's how Ethereum generates keys programmatically (Go implementation):
package main
import (
"crypto/ecdsa"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"golang.org/x/crypto/sha3"
)
func main() {
privateKey, err := crypto.GenerateKey()
if err != nil {
log.Fatal(err)
}
privateKeyBytes := crypto.FromECDSA(privateKey)
fmt.Println(hexutil.Encode(privateKeyBytes)[2:]) // Private key
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("type assertion failed")
}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
fmt.Println(hexutil.Encode(publicKeyBytes)[4:]) // Public key
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
fmt.Println(address) // Ethereum address
}Key steps:
- Generate random private key (256-bit)
- Derive public key from private key
- Convert public key to Ethereum address via Keccak-256 hashing
- Take last 20 bytes as final address
ECDSA: The Signature Algorithm Behind Ethereum
What is ECDSA?
Elliptic Curve Digital Signature Algorithm combines:
- Elliptic Curve Cryptography (ECC)
- Digital Signature Algorithm (DSA)
Core functions:
- Generates key pairs (public/private keys)
- Creates cryptographic signatures with private key
- Verifies signatures with public key
๐ Deep dive into ECDSA security
ECDSA Signature Process
- Select elliptic curve parameters (Ep(a,b)) and base point G
- Choose private key k (where k < n, n being the curve's order)
- Calculate public key Q = k * G
For signing:
- Generate random number r
- Calculate (x,y) = r * G
- Signature components: (r, s)
For verification:
- Confirm signature matches public key
FAQ Section
Q: Can I recover my private key from my Ethereum address?
A: No. Ethereum addresses are one-way hashes of public keys, which themselves are derived from private keys. The process cannot be reversed.
Q: Why does my wallet show a different address case than blockchain explorers?
A: Wallets typically display EIP-55 checksum addresses while explorers accept any case format but internally convert to checksum for validation.
Q: How secure are 12-word mnemonic phrases?
A: Extremely secure. A 12-word phrase has 128 bits of entropy, making brute-force attacks practically impossible with current technology.
Q: What happens if I lose my private key but have my public key?
A: Without the private key, you cannot sign transactions or access funds. Always backup your private key or mnemonic phrase securely.
Q: Why does Ethereum use Keccak-256 instead of standard SHA-256?
A: Keccak-256 (used in Ethereum) has different padding rules than SHA-256, making it more resistant to certain types of cryptographic attacks.
Q: Can two different private keys generate the same public address?
A: Theoretically possible but astronomically unlikely due to the enormous size of Ethereum's key space (2^256 possible private keys).