You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that when this library pulls in bip39 as 3.1.0 we are getting incorrect key pairs from seed phrase to key pair generation.
There is some strange behavior going on here. The seed produced by bip39 remains the same each time we run it. But later on in the generate part of human-crypto-keys we see the results start to differ.
// src/testme.jsimport{getKeyPairFromMnemonic}from"./index.js";import*asbip39from"bip39";constmnemonic="slender during cost problem tortoise extra deal walnut great oblige planet kid";(async()=>{constseedBuffer=awaitbip39.mnemonicToSeed(mnemonic);constseedBuffer2=awaitbip39.mnemonicToSeed(mnemonic);console.log("seed buffer to hex string from bip 39 mnemonic to seed are the same?",seedBuffer.toString("hex")===seedBuffer2.toString("hex"));const{ privateKey }=awaitgetKeyPairFromMnemonic(mnemonic,{id: "rsa",modulusLength: 4096,},{privateKeyFormat: "pkcs8-pem"});const{privateKey: privateKey2}=awaitgetKeyPairFromMnemonic(mnemonic,{id: "rsa",modulusLength: 4096,},{privateKeyFormat: "pkcs8-pem"});console.log("private keys are the same after get key-pair from mnemonic?",privateKey===privateKey2);})();
Results on bip393.0.2:
> node lib/testme.js
seed buffer to hex string from bip 39 mnemonic to seed are the same?true
private keys are the same after get keypair from mnemonic?true
Results on bip393.1.0:
> node lib/testme.js
seed buffer to hex string from bip 39 mnemonic to seed are the same?true
private keys are the same after get keypair from mnemonic?false
In the version 3.1.0, the bip39 package changed their dependencies substantially and added @noble/hashes. This new dependency seems to alter several global cryptos. I still don't yet understand why this would effect the outcome given that the result from bip39 remains the same -- but locking the version of bip39 to 3.0.2 does fix the issue on our end...
The text was updated successfully, but these errors were encountered:
The previous implementation used the bip39 library incorrectly. Instead of the current approach, we should directly use the buffer returned by bip39.mnemonicToSeed.
Closesipfs-shipyard#28
It seems that when this library pulls in
bip39
as3.1.0
we are getting incorrect key pairs from seed phrase to key pair generation.There is some strange behavior going on here. The seed produced by
bip39
remains the same each time we run it. But later on in thegenerate
part ofhuman-crypto-keys
we see the results start to differ.Results on
bip39
3.0.2
:Results on
bip39
3.1.0
:In the version
3.1.0
, thebip39
package changed their dependencies substantially and added@noble/hashes
. This new dependency seems to alter several global cryptos. I still don't yet understand why this would effect the outcome given that the result frombip39
remains the same -- but locking the version ofbip39
to3.0.2
does fix the issue on our end...The text was updated successfully, but these errors were encountered: