Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ObjectInSpace on November 10, 2025, 06:28:59 AM



Title: Casascius Minikey Tool
Post by: ObjectInSpace on November 10, 2025, 06:28:59 AM
Hi all,

I wrote a simple tool for expanding minikeys (https://en.bitcoin.it/wiki/Mini_private_key_format).

Given the minikey, it outputs the corresponding address, and private key in wallet import format.

Example:

Code:
iex> Minikey.expand("S4b3N3oGqDqR5jNuxEvDwf")
[
  mode: :uncompressed,
  minikey: "S4b3N3oGqDqR5jNuxEvDwf",
  address: "1GAehh7TsJAHuUAeKZcXf5CnwuGuGgyX2S",
  private_key: "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ",
  raw_public_key: "04d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645cd85228a6fb29940e858e7e55842ae2bd115d1ed7cc0e82d934e929c97648cb0a",
  raw_private_key: "0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d"
]

This tool is only 100 lines of code, has no dependencies other than the programming language, and can be run completely offline.

https://codeberg.org/objectinspace/minikey


Title: Re: Casascius Minikey Tool
Post by: BattleDog on November 12, 2025, 01:05:17 PM
That's actually a neat little tool. A minikey format is 30 Base58 chars starting with "S" (there's also a legacy 22-char variant from early Series 1 coins).

The validity check for these is super specific: You append "?" to the minikey and SHA-256 it and if the first byte isn't 0x00, you reject it. The actual private key is just SHA-256(minikey).

That's the whole trick, and it's worth, I think, making the tool scream loudly when the check fails.


Title: Re: Casascius Minikey Tool
Post by: ObjectInSpace on November 13, 2025, 02:35:33 PM
That's actually a neat little tool. A minikey format is 30 Base58 chars starting with "S" (there's also a legacy 22-char variant from early Series 1 coins).

The validity check for these is super specific: You append "?" to the minikey and SHA-256 it and if the first byte isn't 0x00, you reject it. The actual private key is just SHA-256(minikey).

That's the whole trick, and it's worth, I think, making the tool scream loudly when the check fails.

Thanks for the comment!

The tool actually handles all of this. 8)


Title: Re: Casascius Minikey Tool
Post by: nc50lc on November 14, 2025, 05:17:45 AM
That's the whole trick, and it's worth, I think, making the tool scream loudly when the check fails.
The tool actually handles all of this. 8)
It just says "Invalid minikey, typo?" when the checksum failed though.
It's not loud enough for him. (jk)

Anyways, I think the length should be 30 by default since the previous 22 is depreciated.
Even if its "generate" feature is suggested to use for testing purposes only, some people will undoubtedly use it given that it's now referenced in mini private key Bitcoin Wiki article. (ref (https://en.bitcoin.it/wiki/Mini_private_key_format#Conversion_tools))


Title: Re: Casascius Minikey Tool
Post by: ObjectInSpace on November 14, 2025, 06:29:34 AM
Anyways, I think the length should be 30 by default since the previous 22 is depreciated.
Even if its "generate" feature is suggested to use for testing purposes only, some people will undoubtedly use it
That's a good point, thanks. I've updated the default length to 30.