TECHNICAL_DOC // KEYS / WIF-PRIVATE-KEY
WIF
PRIVATE KEY
PRIVATE KEY
WIF (Wallet Import Format) is a Base58Check encoding of a raw private key,
designed for human readability and error detection. A WIF key starts with "5" (uncompressed),
"K" or "L" (compressed), and includes a 4-byte checksum to catch transcription errors.
It is the standard format for exporting and importing private keys between Bitcoin wallets.
WIF_ENCODING
WIF ENCODING PROCESS
Input: 32-byte raw private key
Step 1: Add version byte prefix
0x80 ← mainnet (0xEF for testnet)
[0x80] + [32 bytes private key]
= 33 bytes
Step 2: (Optional) Add compression flag
If compressed pubkey intended:
[0x80] + [32 bytes key] + [0x01]
= 34 bytes
Step 3: Compute checksum
checksum = SHA256(SHA256(payload))[0:4] (first 4 bytes)
Step 4: Append checksum
payload + checksum = 37 or 38 bytes
Step 5: Base58Check encode
→ WIF string (51 or 52 characters)
Results:
Uncompressed (33 bytes data): starts with "5" (51 chars)
Compressed (34 bytes data): starts with "K" or "L" (52 chars)
Example — Compressed vs Uncompressed WIF
FORMATS
The presence or absence of the 0x01 flag-wif-0x01/">compression flag determines whether the derived public key will be compressed (33 bytes) or uncompressed (65 bytes).
Same raw private key, two WIF encodings:
Raw: 0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d
Uncompressed WIF (prefix 0x80, no 0x01 suffix):
5HueCGU8rMjxECyDialwujznE7b3vGh5sSyz8BRqUMm4dqNcV
Compressed WIF (prefix 0x80, 0x01 suffix appended):
KwntMbt59tTsj8xqpqYqRRWufyjGunvhSyeMo3NTYpFYzZbXJ5
"K" or "L" prefix signals: use compressed public key
"5" prefix signals: use uncompressed public key
Modern wallets always use compressed keys.
Uncompressed keys are legacy (pre-2012).
Network Prefixes
MAINNET / TESTNET
The version-byte-base58check/">version byte in WIF determines which network the key is for, producing distinctly different first characters in the final Base58Check string.
Mainnet: version byte = 0x80
Compressed: starts with "K" or "L"
Uncompressed: starts with "5"
Testnet: version byte = 0xEF
Compressed: starts with "c"
Uncompressed: starts with "9"
Signet/Regtest: same as testnet (0xEF)
TERMINOLOGY_INDEX
WIF
Wallet Import Format. Base58Check encoding of a raw private key with version byte and checksum.
Compression Flag
0x01 byte appended before checksumming to indicate the compressed public key should be used.
Base58Check
Encoding using 58 alphanumeric characters (no 0/O/l/I) plus a 4-byte checksum for error detection.
Version Byte
0x80 for mainnet. Determines the starting character of the WIF string.
INTERACTIVE — TRY IT YOURSELF
KEYS / ENCODING
WIF Private Key
Wallet Import Format (WIF) is a Base58Check encoding of a raw private key with a version byte of
0x80. An optional 0x01 compression flag byte signals that the corresponding public key should be in compressed form. WIF strings starting with 5 = uncompressed; K or L = compressed.
RAW HEX → WIF ENCODER
PRIVATE KEY → WIFadds version byte + checksum
COMPRESSED (K/L prefix)
UNCOMPRESSED (5 prefix)
WIF DECODER
WIF → RAW KEY + VALIDATION
Why K and L? A compressed WIF key starts with
0x80 || 32-byte-key || 0x01 = 34 bytes payload. After Base58Check encoding of 38 total bytes, the result mathematically always starts with K or L depending on the first nibble of the key. Uncompressed (33-byte payload, 37 total bytes) always starts with 5.