Mini private key format
The mini private key format is a method of encoding a Bitcoin private key in 22 characters so that it can be embedded in a small space. This private key format was first used in Casascius physical bitcoins, and is also favorable for use in QR codes which allows use of a lower dot density. The format offers a built-in check code as a small margin of protection against typos.
An example key using this encoding is SKeG8GMRuXCJRCghy5DnCy.
The private key encoding consists of 22 alphanumeric characters from the base58 alphabet used in Bitcoin. The first of the 22 characters is always the uppercase letter S.
To obtain the full 256-bit private key, simply take the SHA256 hash of the entire string.
SHA256("SKeG8GMRuXCJRCghy5DnCy") = 6C694094F4EB853325778A2A47B5ED75072D7E1ABC7428213A5D07D620BF9A33
The check code is designed to be simple, but relatively computationally expensive so that it cannot be used to quickly reduce the key space. It offers seven bits worth of error protection (or, in other words, in the event of a typo, the typo will be caught about 127 out of 128 times, or over 99%).
To determine whether a string passes the check code, follow these steps:
- Ensure it is well-formed (22 characters, base58 alphabet, starts with S).
- Add a question mark to the end of the string, and take the SHA256 of that. If the SHA256 starts with eight zero bits (hex 00), then the string passes the check code.
- If it does not, then with the same string (ending in a question mark), do 717 (seven hundred seventeen) rounds of SHA256 on the string. If the result after the 717th round starts with eight zero bits (hex 00), then the string passes the check code.
- If the result doesn't start with eight zero bits, then the check fails.