MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.87k stars 4.85k forks source link

Add option to export Extended Public Key (Xpub) #3964

Open levz0r opened 6 years ago

levz0r commented 6 years ago

Hello, This is a feature request. It would be great to have an option to export the Xpub key of my wallet(s).

Thank you

danfinlay commented 6 years ago

This could also be easily achieved by a 3rd party developer, by creating a simple Dapp that uses one of our supported signature methods to recover the public key.

amal commented 6 years ago

@danfinlay can you provide some code example?

I'm not very familiar with Web3 API, just started. And atm don't understand how I can achieve extended public key exporting with MetaMask

amal commented 6 years ago

Can anybody help with this?

Seems like no one on stackoverflow can help too: https://ethereum.stackexchange.com/questions/48337/how-to-export-extended-master-public-key-from-metamask

danfinlay commented 6 years ago

You can use one of our signature methods to get a signature, and then use something like eth-sig-util to extract a public key from that signature.

This is just a single account's public key, though. I'm not very familiar with xpubs or their security features. We use ethereumjs-wallet under the hood, and it supports a few xpub methods, so we could presumably expose some xpub methods, but this would be an API changing feature request.

I would recommend submitting this as a proposal to Ethereum Magicians, so we can get some expert opinions on that potential feature.

EvilJordan commented 6 years ago

@danfinlay It's definitely not possible to determine an xPub from a single sub pub/priv keypair. That would be a massive security leak and design flaw if that were the case.

You are correct there are methods to support export/display of the xPub key with ethereumjs (https://github.com/ethereumjs/ethereumjs-wallet/blob/cfe0f600880dc6df666f769e54c210ee05bcad47/README.md#hd-wallet-api), but these rely on knowing the seed phrase or the xPub/xPriv keys themselves. As I understand it, MM doesn't remember this information after the first time it's displayed, so maybe it's not possible?

I apologize for asking what may be an ignorant question, but what is the roll of Ethereum Magicians with regards to MetaMask? Why is it better to post a proposal there rather than directly with MM?

danfinlay commented 6 years ago

Thanks for clarifying, @EvilJordan.

Ethereum Magicians is meant to be a better EIP forum, where any cross-client standard (including new web3 methods) could be passed by the community.

It's especially useful when a method proposed would be cross-client, and so require buy-in from multiple clients (ideally), which is why this could be useful if you wanted Dapps to be able to request an xPub key.

waterdrop01 commented 5 years ago

That should be a UI only option (not API), similar to the private key export.

That option could be very usefull for importing into a watch only wallet. I also opened a feature request on MEX => https://github.com/MyEtherWallet/MyEtherWallet/issues/687

That's a very common feature with Bitcoin, that should gain traction in Ethereum imo...

deknowny commented 2 years ago

Any solution in existing wallets for this?