When creating a private key, how would I ensure that there is a mini private key equivalent, which could be substituted in place of the the full private key? What math would I have to use to create such a private key for bitcoins?
You can't create a minikey for a private key - you need to create a private key once you've created a minikey.
You need to ensure that the SHA256 of the mini key plus a question mark after it has a hash starting with
Or, in Python:
sha256(candidate + "?") == chr(0)
The following Python program will generate mini keys:
import hashlib from binascii import hexlify as hx import random rand = random.SystemRandom() B58_ALPHA = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" def sha256(s): return hashlib.sha256(s).digest() def gen_candidate(): candidate = "S" for i in xrange(29): candidate = candidate + rand.choice(B58_ALPHA) return candidate def test_candidate(candidate): return sha256(candidate + "?") == chr(0) while True: c = gen_candidate() if test_candidate(c): print c, hx(sha256(c))