Key Pair
A private key and the public key derived from it, the basis of ownership and signatures.
Basically
A key pair is a matched public key and private key. You use it for encryption, signing and identity in cryptocurrency.
Key Takeaways
- A key pair has a private key that you keep secret and a mathematically linked public key that you can share freely. Together, they enable ownership, signing and verification across all cryptocurrency systems.
- Elliptic curve cryptography generates key pairs. Your private key is a random 256-bit number, and your public key comes from it through a one-way mathematical function that cannot be reversed.
- Every cryptocurrency transaction uses key pairs for digital signatures. Your private key signs transactions to prove ownership, and your public key lets anyone verify the signature without learning your secret.
What Is a Key Pair?
A key pair is the basic cryptographic unit behind all cryptocurrency ownership and transactions. It has two mathematically related values: a private key that only you know and a public key that you can share with anyone. Your private key proves you own funds, while your public key lets others verify that proof without seeing the secret.
Bitcoin and most cryptocurrencies use key pairs instead of the username-and-password model of traditional finance, with no central authority to store your credentials or reset your access. Your private key is your identity: whoever holds it controls the associated funds. Your public key, or an address derived from it, lets others send you payments.
The two keys have an asymmetric relationship. Deriving the public key from the private key is trivial, but reversing the process is computationally infeasible, and this one-way property secures the entire system.
How It Works
Bitcoin uses the secp256k1 elliptic curve to generate key pairs. The curve is defined by the equation y² = x³ + 7 over a large finite field, and the process has two steps:
The elliptic curve discrete logarithm problem makes this scheme secure. Given the public key Q and the generator point G, no efficient algorithm can recover the private key d, and a 256-bit key provides approximately 128 bits of security, so an attacker would need roughly 2¹²⁸ operations to break it.
Key Formats and Encoding
Private and public keys can use several formats. The format depends on the context:
Compressed public keys are the modern standard. The y-coordinate can be derived from x using the curve equation, so only the x value and a single prefix byte need to be stored, with the prefix byte indicating which of two possible y values to use. Compression halves the public key size and reduces transaction fees.
From Key Pair to Address
A Bitcoin address is not the public key itself but a hash derived from it. SHA-256 and RIPEMD-160 process the public key to produce a shorter, checksum-protected address. Different address types (P2PKH, P2WPKH, P2TR) use different encoding schemes, but all originate from the same key pair.
Signing and Verification
Key pairs enable two core cryptographic operations. These operations power every transaction:
Bitcoin originally used ECDSA signatures (70-72 bytes). The Taproot upgrade (activated November 2021) introduced Schnorr signatures via BIP-340, which produce 64-byte signatures with 32-byte x-only public keys. Schnorr's linearity property enables advanced features like key aggregation (MuSig2) and threshold signatures (FROST), making multisig transactions indistinguishable from single-key spends on chain.
Code Example
The code example uses common libraries to generate a key pair and derive a Bitcoin address. It covers both steps:
HD Wallets and Key Derivation
Modern wallets do not manage individual key pairs in isolation. They use hierarchical deterministic (HD) wallets defined by BIP-32, where a single master seed, typically encoded as a seed phrase, generates an entire tree of key pairs through deterministic derivation using HMAC-SHA512.
BIP-44 standardises the derivation path structure. The path follows this structure:
You only need to back up a single seed phrase to recover all your key pairs and associated funds. Each address in your wallet corresponds to a unique key pair derived from the same root.
Transaction Authorization
Every Bitcoin transaction requires a valid signature from the private key controlling the spent outputs. The network verifies this signature against the public key before including the transaction in a block. Funds cannot move without the correct key pair.
Multi-Signature Security
Multisig wallets combine multiple key pairs into a single spending policy, such as 2-of-3. They distribute trust across multiple keys, so no single compromised key pair can authorise a transaction. Threshold signature schemes like FROST go further by aggregating multiple key pairs into a single on-chain public key using protocols like FROST threshold signatures.
Identity and Authentication
Key pairs also serve as identity anchors across cryptocurrency protocols beyond transactions. Lightning Network nodes identify themselves by their public keys, and Nostr uses secp256k1 key pairs for decentralised identity. Decentralised identity systems use key pairs to issue and verify credentials without centralised authorities.
Layer 2 Protocols
Layer 2 systems like Spark rely on key pairs for off-chain transaction signing and ownership verification. In Spark, key pairs let you hold and transfer virtual UTXOs with full self-custody: your private key remains the ultimate authority over your funds, even though transactions settle off the base layer. The Spark layer 2 deep dive explains more about how this works.
Key Loss
A lost private key makes the associated funds permanently inaccessible if no backup exists. No password reset, customer support or protocol-level recovery mechanism exists. Seed phrase backups and proper key management practices are therefore essential.
Key Compromise
An attacker who obtains a private key gains full control over the associated funds. Common attack vectors include malware, phishing, insecure storage and weak random number generation during key creation. Hardware wallets and air-gapped signing devices reduce this risk by keeping private keys isolated from internet-connected systems.
Quantum Computing Threats
Quantum computers running Shor's algorithm could theoretically solve the elliptic curve discrete logarithm problem and recover private keys from public keys. As of 2026, no quantum computer is close to the required scale, estimated at hundreds of thousands of physical qubits for secp256k1, but the threat has motivated research into post-quantum cryptography for future Bitcoin upgrades. Addresses that have never exposed their public key on chain, because they have only received and never spent, have an extra layer of protection since attackers would need to break both the hash function and the elliptic curve.
Address Reuse
Reusing the same key pair for multiple transactions reduces privacy by linking activity to a single public key. It also increases quantum exposure because broadcasting a transaction reveals the public key on chain. You should avoid address reuse by generating a fresh key pair through HD derivation for each transaction.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.