bip32 hd wallets – Storing total seed from bip39 mnemonic utilizing WIF – CoinNewsTrend

bip32 hd wallets – Storing total seed from bip39 mnemonic utilizing WIF

[ad_1]

I am utilizing the bitcoinjs assortment of libraries, particularly https://github.com/bitcoinjs/wif, https://github.com/bitcoinjs/bip32 and https://github.com/bitcoinjs/bip39 with nodejs.

I’ve a mnemonic and might get the seed of it utilizing bip39:

> const mnemonic="laptop computer arrest vast slice prolong right now jelly bachelor curiosity related particles behind"
> const seed = bip39.mnemonicToSeedSync(mnemonic)
> seed
<Buffer 11 ae 55 c9 cb c0 c8 5c 09 d2 4e 36 4a 90 a6 64 09 fe 2b 87 47 79 4a 7b 03 39 76 ff 4b e9 28 59 84 74 81 cf 07 a2 7f c6 91 67 ec 04 7c a3 dc d9 23 9b ... 14 extra bytes>

Nonetheless, encoding it utilizing wif after which decoding it solely accommodates the primary 16 bytes of the seed:

> wif.decode(wif.encode(0x80, seed, true)).privateKey
<Buffer 11 ae 55 c9 cb c0 c8 5c 09 d2 4e 36 4a 90 a6 64 09 fe 2b 87 47 79 4a 7b 03 39 76 ff 4b e9 28 59>

It is a drawback as a result of after I use bip32.fromSeed, the derived keys will not be the identical. Utilizing bip32.fromPrivateKey solves this concern, however provided that I’ve the chaincode, which nonetheless must be in some way saved individually.

What am I doing unsuitable? Thanks prematurely. When utilizing mnemonics, am I speculated to discard a part of the seed so it aligns with the WIF?

[ad_2]

Supply hyperlink