1

I'm creating a dapp. and I need my users on my website to provide public keys. As I am lazy to write a script which generates public/private keys automatically, I want to suggest an idea that they use a public key from metamask. I go to metamask and All i can see is the address and private key. There's no public key at all. Please don't tell me that address and public key are both the same. THat's not true. Address is the 160 hash of public key.

So my question is how do I get the public key from metamask?

  • You need to have MetaMask sign a random message, and use ECIES (which, I believe, ethereumjs-util implements) to derive the public key from the signature and the message hash. – Henk Sep 14 '18 at 12:44
  • Thanks guys. I'll try to see that. BY the way, Is it possible to get the private key from metamask by using web3? – Giorgi Lagidze Sep 14 '18 at 13:31
  • No, metamask doesn't provide the private key to web3. – AnAllergyToAnalogy Sep 14 '18 at 13:50