Understanding the Difference in Public Keys Made of Metamask and Ethereum
As Ethereum developers, we are not foreigners for little interactions with Ethereum blockchain. Recently, several users are confused by deviating between public key
Question: Different Public Keys From The Same Private Key
Let’s dive into the details of what is happening. When However, this public key is calculated on the basis of a private key stored in a metamic. Here’s Why:
* Private key: Private key used to create an Ethereum Wallet is unique to each individual.
* Calculation of public key:
Instead, it is a different calculation method, which generates a new set of keys (public and private)
* Common Secret: This common secret is used to get a public key from a private key.
Solution: RecocwuBuBlexy ()
Vs. eth_getencryancepubliscney '
To feel this problem, you can use any of the two methods:
- Recovepublickey ()
:
.
.
- eth_getencryplpublisckey
(RPC):
*
* However,?
Example Code: Return of a Public Key With A MetamascusRecocwuBuBlexy ()
JavaScript
Const Web3 = required (‘Web3’);
Const Metamascus = New Web3 (New Web3.providers.httpprovider (‘
Metamask.getaccounts (). Then (accounts => {
Const publicky = accounts [0] .getpublkyy ();
// Recovery of a Private Key Using a Metamascus Recoublickey Method
Return Metamask.RecoverpublisCkey (Publickey);
});
`
Conclusion:
The deviation between public key Understanding How Ethereum Addresses, Private Keys and Common Secrets Work together, You will be better equipped to move in these complex interactions.
If you have any questions or you need a further clarification of this topic, feel free to ask!