Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: rheticus on March 06, 2023, 07:31:04 PM



Title: Mini private key format
Post by: rheticus on March 06, 2023, 07:31:04 PM
I want to understand why the format for a mini private key necessarily has to always start with an "S". Why is this? Is there a specific reason for it? I would imagine so but I dont know what it might be.


Title: Re: Mini private key format
Post by: Upgrade00 on March 06, 2023, 08:08:40 PM
I'm not aware of any particular reason for this distinction. Most likely it's for identification, just how segwit addresses, legacy addresses and even compressed and uncompressed private keys start with a particular character(s).

You could also wait for other members who may have more appropriate answers to respond, if there is such answer.


Title: Re: Mini private key format
Post by: UdtaParinda1 on March 06, 2023, 08:21:43 PM
The basic answer to this question which you can google as well is Base58Check encoding. There serval reason for the S to be used as you know in the mini private keys there some uppercase, lowercase and Numbers mixture with the total 30 characters. So sometimes what happen people gets confused with the 0 and O for this reason in Base58Check encoding for error free encoding of data eliminates such latter's and numbers.
Simple answer is because its Base58Check so it starts with "S" as for the public keys there some standards.

  • Taproot address - P2TR : bc1p
  • Bech32 / Segwit: bc1q
  • Script address: 3
  • Legacy address: 1  

You could also wait for other members who may have more appropriate answers to respond, if there is such answer.

There is no such answer as its commonly considered because of its encoding type..




Title: Re: Mini private key format
Post by: hosseinimr93 on March 06, 2023, 08:56:34 PM
There serval reason for the S to be used as you know in the mini private keys there some uppercase, lowercase and Numbers mixture with the total 30 characters.
It may worth mentioning that a mini private key can be also in 22 character format.
For more information, visit Mini private key format (https://en.bitcoin.it/wiki/Mini_private_key_format) on Bitcoin Wiki.


Title: Re: Mini private key format
Post by: witcher_sense on March 07, 2023, 06:19:36 AM
I want to understand why the format for a mini private key necessarily has to always start with an "S". Why is this? Is there a specific reason for it? I would imagine so but I dont know what it might be.
The reason why mini private keys always start with the uppercase letter "S" is that cryptocurrency users need to somehow distinguish important information from random gibberish. That is why standards exist. For example, if you are familiar with standards describing the creation of these mini private keys, every time you see a string starting with "S" and consisting of 30 characters, you immediately assume that it is a key that can be converted to another key. But how do you know how to convert it? Again, mini private key specifications describe the process: just take a sha256 of a given string, convert it to WIF format, and import it to your wallet. Without standards dictating in which format data needs to be written to be distinguished from other types of data, you would have to try hundreds of different algorithms to convert it to a correct output.


Title: Re: Mini private key format
Post by: tbct_mt2 on March 07, 2023, 11:07:02 AM
Simple answer is because its Base58Check so it starts with "S" as for the public keys there some standards.

  • Taproot address - P2TR : bc1p
  • Bech32 / Segwit: bc1q
  • Script address: 3
  • Legacy address: 1  
They are public addresses, not public key, not private key.

Private key has some representations: Raw, Hex, WIF, WIF-compressed. Private key formats (Mastering Bitcoin) (https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc)

With WIF, WIF-compressed formats, you can recognize them by prefix (WIF with prefix 5; WIF-compressed with prefix K or L).


Title: Re: Mini private key format
Post by: pooya87 on March 07, 2023, 12:30:50 PM
@Upgrade00 is correct, the letter S is simply for identification of mini private keys, in fact if you look at the original source code you can see that S is simply added to the start of the randomly generated string[1] instead of being a meaningful version integer as is normal with other base58 encodings like addresses.

[1] https://github.com/casascius/Bitcoin-Address-Utility/blob/dcfc3b99a3df1427fc19fcfbe18c1bfedfdad4eb/Model/MiniKeyPair.cs#L50


Title: Re: Mini private key format
Post by: Aanuoluwatofunmi on March 07, 2023, 05:50:31 PM
I want to understand why the format for a mini private key necessarily has to always start with an "S". Why is this? Is there a specific reason for it? I would imagine so but I dont know what it might be.

If you look into bitcoin addresses, you will discover that same pattern of letter is common to each type of address generated, either legacy, taproot or segwit address all have their own unique identification character they begins with, so that once seing any you could easily predict the address type, this is also common to other cryptocurrencies, each have a unique means of identifying their own addresses, but the reason to using this is best known to them, but what we could predict is for easy identification.


Title: Re: Mini private key format
Post by: nc50lc on March 08, 2023, 04:05:44 AM
Maybe the same author but there's a similar question in Bitcoin Stackexchange
and there's an interesting answer that identifies the "S" as "Spend", he didn't included a source though.

Link: bitcoin.stackexchange.com/questions/117486/mini-private-key-format (https://bitcoin.stackexchange.com/questions/117486/mini-private-key-format)


Title: Re: Mini private key format
Post by: pooya87 on March 08, 2023, 04:58:16 AM
"S" as "Spend"
Small makes more sense though since these are indeed "small" strings that are used to derive a private key and we couldn't use "m/M" for mini since "m" is used for addresses on testnet already and could create confusion.


Title: Re: Mini private key format
Post by: nc50lc on March 08, 2023, 06:05:09 AM
and there's an interesting answer that identifies the "S" as "Spend", he didn't included a source though.
Small makes more sense though since these are indeed "small" strings that are used to derive a private key -snip-
I think it's just following the (old) standard paper wallet print format which labels the private key as "Spend".
Notice that in most paper wallet generators or some printable wallet private key exports, the private key is printed with the word 'Spend'.


Title: Re: Mini private key format
Post by: rheticus on April 25, 2023, 08:10:34 PM
Thank you to everybody for the great replies! You are very kind to take the time to explain this thing  :)