1

What function in nodejs, or using the relevant crypto packages (web3, ethers, cryptojs, etc) can do this?

For example, need a function within node that can turn something that looks like this: "twenty four words... that are pass phrase"

into something that looks like this:

"8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f"

Based on another post: Recover all the account under Mnemonic using ethers.js

tried using

w = utils.HDNode.fromMnemonic(keys.mnemonic, m/44'/60'/0'/0/1);

throws 'invalid mnemonic' when using the valid passphrase from an existing wallet.

strangely, the central point of a hardware wallet is to store a private key... yet it may have no mechanism to give the private key back to you directly, no export function. Therefore, the private key must be generated denovo from the passphrase. Yes, I'm aware that the point of a hardware wallet is to keep the private key hidden in hardware and that it'd be risky to put it anywhere else. That said, need a private key to test live crypto transactions with.

Thanks

1 Answer 1

0

You can simply try out the code below

const ethers = require('ethers')
const randomMnemonic = ethers.Wallet.createRandom().mnemonic;
console.log('randomMnemonic',randomMnemonic)
const wallet = ethers.Wallet.fromMnemonic(randomMnemonic.phrase);
console.log('wallet',wallet._signingKey())

Output

randomMnemonic {
  phrase: 'guitar culture pigeon rebuild prefer vicious patient quiz excess final field fantasy',
  path: "m/44'/60'/0'/0/0",
  locale: 'en'
}
wallet SigningKey {
  curve: 'secp256k1',
  privateKey: '0xdef5a68864976ece00c6d6bb7550965d42fcec671a81d56e74d5a3ef5a8fabe4',
  publicKey: '0x0496f758fda94096242dfc303dcec0aab1f163b8abcd2f7c61d13b85d6ab4e7c40c4f6e12d95eb2da01d470a4a4e55891c242b19e62ca622d4995cf674a32538a0',     
  compressedPublicKey: '0x0296f758fda94096242dfc303dcec0aab1f163b8abcd2f7c61d13b85d6ab4e7c40',
  _isSigningKey: true
}

You can also see this one HERE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.