0

Using ethers, I can easily generate a public key (wallet address), private key, and seed phrase:

function makeWallet(params) {
    const wallet = ethers.Wallet.createRandom();
    return [wallet.address, wallet.mnemonic.phrase, wallet.privateKey];
}

Question:

What is the relationship between the mnemonic phrase, the private key, and the address? I cad divide the question into 3 sub-parts:

  • Given a wallet address, and a mnemonic key, is it possible to compute the private key?
  • Given a wallet address, and a private key, is it possible to compute the mnemonic key?
  • Given a mnemonic key and/or private key, is it possible to compute the wallet address?
2
  • The mnemonic is the seed that generate 1 to many private keys. From private key you cannot go back to the mnemonic.
    – Majd TL
    May 23, 2022 at 16:27
  • So it is Yes, No, Yes. Anyway you must keep private key and mnemonic secret.
    – Majd TL
    May 23, 2022 at 16:29

1 Answer 1

1

Given a wallet address, and a mnemonic key, is it possible to compute the private key?

If you have the mnemonic, it's possible to compute a number of private keys, and their corresponding addresses.

Given a wallet address, and a private key, is it possible to compute the mnemonic key?

No.

Given a mnemonic key and/or private key, is it possible to compute the wallet address?

Yes, given a private key, it is possible to compute the wallet address corresponding to it. Mnemonic is not necessary.

This is the usual flow of wallets: Private key => Public key => Address. The arrow "=>" represents the direction of the one-way function. Then people used a lot of wallets, i.e. they had to manage a lot of private keys, and hence it led to creation of the BIP-32, BIP-39 standards, which describes mnemonic and how one can deterministically generate lot of private keys from it. So user just needs to hold mnemonic for any number of wallets (private keys).

This site can be helpful for playing around: https://iancoleman.io/bip39/

In ethers.js there is a thing called HDNode that allows to handle lot of wallets with just a single mnemonic. If interested, you may check it out here: https://docs.ethers.io/v5/api/utils/hdnode/

Your Answer

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

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