While developing a wallet application, I realized it's essential to have a solid understanding of how private and public keys work. These fundamentals are not just academic โ they directly influence how securely and efficiently a wallet operates.
๐ What Is a Private Key?
A private key is a randomly generated 256-bit (32-byte) number. It gives full control over a walletโs funds.
Example:
0C28FCA386C7A2276AC8192E9F6DDEDC6D1E2C140C3C7A75A2B708F3EDF5BE59
There are 2^256 possible keys โ more than atoms in the universe โ making it virtually unguessable.
๐ What Is a Public Key?
The public key is derived from the private key using elliptic curve cryptography (ECC). In Bitcoin, this is done with the secp256k1
curve. It's a one-way process โ safe and irreversible.
๐งพ How Is an Address Created?
- Start with public key
- Hash it (SHA-256 โ RIPEMD-160)
- Add version byte
- Add checksum
- Base58Check encode the result
This becomes a Bitcoin address.
๐ Key Derivation Diagram
[ Private Key ]
โ
[ Public Key ]
โ
[ Public Key Hash ]
โ
[ Address ]
๐ฒ HD Wallets in a Nutshell
Later in this journey, weโll explore HD Wallets in more depth โ especially how they're implemented in Rust and used to generate secure, deterministic key hierarchies for modern wallet applications.
HD (Hierarchical Deterministic) wallets generate thousands of addresses from a single seed using a structured path like:
m / 44' / 0' / 0' / 0 / 0
Only the seed phrase needs to be backed up.
๐ก Why Different Formats Exist
Format | Blockchain | Purpose |
---|---|---|
WIF | Bitcoin | Encodes private keys with checksum and compression flag |
Hex | Ethereum | Raw private keys, no metadata |
JSON | Solana | Full Ed25519 keypair stored as JSON array |
SS58 | Polkadot | Includes network prefix + checksum |
Each format is optimized for the platformโs cryptography and UX.
Top comments (0)