Friday, January 17, 2025
HomeBitcoinHow you can generate a sound hash for a bip39 seed phrase?

How you can generate a sound hash for a bip39 seed phrase?


Generally it’s simpler to work backwards from the reply. To take this method let’s begin with particulars for Bitcoin explorer’s subcommand mnemonic-new. Let’s additionally assume the 256 bit hash is reprsented as hex as 87C1B129FBADD7B6E9ABC0A9EF7695436D767AECE042BEC198A97E949FCBE14C.

% echo -n 87C1B129FBADD7B6E9ABC0A9EF7695436D767AECE042BEC198A97E949FCBE14C | bx mnemonic-new

march assault engine warrior expertise swarm pluck job put together knife pipe man pupil cube obtain analyst salute artwork clear wooden enemy vacationer lunch like

The 24 seed phrase line numbers are taken immediately from https://github.com/bitcoin/bips/blob/grasp/bip-0039/english.txt:

1087 109 596 1979 1772 1756 1334 961 1360 990 1323 1079 1724 492 1437 67 1527 103 339 2026 592 1840 1066 1038

1086         108          595          1978         1771         1755
0x43E        0x06C        0x253        0x7BA        0x6EB        0x6DB
010000111110 000001101100 001001010011 011110111010 011011101011 011011011011
 10000111110  00001101100  01001010011  11110111010  11011101011  11011011011 
 8   7   C     1   B   1     2   9   F     B   A     D   D   7     B   6   E

1333         960          1359         989          1322         1078
0x535        0x3C0        0x54F        0x3DD        0x52A        0x436
010100110101 001111000000 010101001111 001111011101 010100101010 010000110110
 10100110101  01111000000  10101001111  01111011101  10100101010  10000110110
   9   A   B     C   0     A   9   E     F   7   6     9   5   4     3   6

1723         491          1436         66           1526         102
0x6BB        0x1EB        0x59C        0x042        0x5F6        0x066
011010111011 000111101011 010110011100 000001000010 010111110110 000001100110
 11010111011  00111101011  10110011100  00001000010  10111110110  00001100110
 D   7   6     7   A   E     C   E   0     4   2     B   E   C     1   9   8

338          2025         591          1839         1065         1037
0x152        0x7E9        0x24F        0x72F        0x429        0x40D
000101010010 011111101001 001001001111 011100101111 010000101001 010000001101
 00101010010  11111101001  01001001111  11100101111  10000101001  10000001101
   A   9   7     E   9     4   9   F     C   B   E     1   4   C     0   D

Discover all the pieces matches with an extra 0x0D tucked on the top. That is the checksum that’s computed per https://github.com/bitcoin/bips/blob/grasp/bip-0039.mediawiki#generating-the-mnemonic.

The primary 8 bits of a sha256 hash for the instance above drive the checksum 0x0D that’s tucked on to the top.

% bx sha256 87C1B129FBADD7B6E9ABC0A9EF7695436D767AECE042BEC198A97E949FCBE14C
0dc811788c7e02c32b9c4b3586baf58ca27f74330c92d661042b19faa6c7e9f2

Discover all the pieces matches with an extra 0x0D tucked on the top. That is the checksum that’s computed per https://github.com/bitcoin/bips/blob/grasp/bip-0039.mediawiki#generating-the-mnemonic.

The variety of bits to be utilized from the sha256 operation above is a perform of the primary column of this desk. The second column of this desk paperwork the variety of checksum bits that utilized.

The Spanish BIP 39 indexes are an identical to the English index for the equipped 32 bytes of entropy.

% echo 87C1B129FBADD7B6E9ABC0A9EF7695436D767AECE042BEC198A97E949FCBE14C | bx mnemonic-new -l es
manga ánimo elemento vencer sultán soporte oscuro juntar pan látex oreja malla sidra cumplir pilar aldea pupa ancla capitán voraz eje tesoro luz llama

The 24 seed phrase line numbers are taken immediately from https://github.com/bitcoin/bips/blob/grasp/bip-0039/spanish.txt match these above for English above:

1087 109 596 1979 1772 1756 1334 961 1360 990 1323 1079 1724 492 1437 67 1527 103 339 2026 592 1840 1066 1038

The BIP 39 mnemonic-to-seed operation completely IS NOT invertable, and efficient seeds produced will differ wildly amongst BIP 39 language-specific seed phrase lists. Two totally different 512-bit mnemonic-to-seed mechanisms are used under (stretch and bitcoin explorer mnemonic-to-seed) for each English (en) and Spanish (es).

% echo "march assault engine warrior expertise swarm pluck job put together knife pipe man pupil cube obtain analyst salute artwork clear wooden enemy vacationer lunch like" | bx mnemonic-to-seed -l en -p "123"
809839beb19097ccfbe20c62278c9c4801497010f913a133c3d20f563a216a6cf23a5af53c13d778b278069f189aee1bd73452ec7617d935c2631edd93d70284

% stretch -f sha512 -r 2048 "march assault engine warrior expertise swarm pluck job put together knife pipe man pupil cube obtain analyst salute artwork clear wooden enemy vacationer lunch like" mnemonic123 | bx base64-decode | bx base16-encode
809839beb19097ccfbe20c62278c9c4801497010f913a133c3d20f563a216a6cf23a5af53c13d778b278069f189aee1bd73452ec7617d935c2631edd93d70284

% echo "manga ánimo elemento vencer sultán soporte oscuro juntar pan látex oreja malla sidra cumplir pilar aldea pupa ancla capitán voraz eje tesoro luz llama" | bx mnemonic-to-seed -l es -p "123"
4e0159fedf7682323f9a34a8218292faf78277727bf6cc6bb4c7f833d5920318a8dfaad8c91813984ed567fff14e7f59aa4be9890540989de0448d2f86864a4f

% stretch -f sha512 -r 2048 "manga ánimo elemento vencer sultán soporte oscuro juntar pan látex oreja malla sidra cumplir pilar aldea pupa ancla capitán voraz eje tesoro luz llama" mnemonic123 | bx base64-decode | bx base16-encode
4e0159fedf7682323f9a34a8218292faf78277727bf6cc6bb4c7f833d5920318a8dfaad8c91813984ed567fff14e7f59aa4be9890540989de0448d2f86864a4f

Lastly, a top-level hierarchical deterministic prolonged keys may be produced from the 2 512-bit seeds above.

% echo 809839beb19097ccfbe20c62278c9c4801497010f913a133c3d20f563a216a6cf23a5af53c13d778b278069f189aee1bd73452ec7617d935c2631edd93d70284 | bx hd-new
xprv9s21ZrQH143K2yEY3QSoUzx5i1ZL3rMJX4C5XikitLQruPj23MTBLhU1EiZkpQNidPxKhCR548zUpw261gJZ8x6scyQeCE67Tr2v1bAn8cx

% echo 4e0159fedf7682323f9a34a8218292faf78277727bf6cc6bb4c7f833d5920318a8dfaad8c91813984ed567fff14e7f59aa4be9890540989de0448d2f86864a4f | bx hd-new
xprv9s21ZrQH143K4SehajoujF9rWwQezrvezd7trUPBgrN1r7WkDiY3fUobvbTmbigW5vhpJzBtURszkiBRRenUapMtbBaGaWtVHL4ZWPcaZcL

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments