Shamir Mnemonics are encoded into 3 components - the Version, the Parameters, and the Shamir Share.
The encoded components are concatenated together to form a Shamir Mnemonic.
First Component is Version The first component is the single word shamir39.
This prevents mixing incompatible mnemonics and allows upgrading the implementation in the future.
Second Component is Parameters The second component specifies the parameters of Shares Required (M) and Share Ordering (O).
It may be encoded to multiple words.
The first bit of the 11 bits of the word indicates if this is the final word used to encode the parameters. A first bit value of 0 indicates this is final word, 1 means continue parsing words.
The next five bits of each word give M
The last five bits of each word give the Order of this share
If the parameters span multiple words, concatenate the bits together to form M and O
Example decoding parameters in a single word 'amused' is index 65 in the English wordlist. This translates to binary 00001000001 left-padded to 11 bits.
00001000001 is parsed into parameters as
0 00010 00001 Final M O The leading zero indicates this is the final word encoding the parameters.
The next five bits give M; M = 00010 = 2, ie 2 shares are required to reconstruct the secret.
The next five bits give O; O = 00001 = 1; ie this should be ordered after share with O=0 but before share with O=2.
Example encoding parameters across multiple words Consider M = 35 = 100011 O = 10 = 1010
Left pad both to multiple of 5 bits
M = 0000100011 O = 0000001010
Split into groups of 5 bits
M = 00001 00011 O = 00000 01010
Convert this into mnemonic words:
The first word is not the final word so it: - starts with 1 - then has the first five bits of M - then has the first five bits of O
1 00001 00000 = 10000100000 = 1056 = "lottery"
The second word is the final word so it: - starts with 0 - then has the second five bits of M - then has the second five bits of O
0 00011 01010 = 00001101010 = 106 = "ask"
So the parameters M = 35 and O = 10 are encoded as "lottery ask" Third Component is The Shamir Share The third component is the data for the shamir share and is a binary blob which must be encoded to mnemonic words.
The binary shamir share is encoded to mnemonic words by:
left pad the binary share to multiple of 11 bits convert each group of 11 bits to the corresponding word in the wordlist The mnemonic words are decoded to the binary shamir share by:
convert each word to the 11 bit binary representation and concatenate together truncate from the left to the required multiple for the specific shamir implementation (in the case of the prototype it's 4 bits)