Understand the difference between public keys from metamascus and ethereum
As creators of Ethereum, we are not foreigners associated with the complexity of interaction with Blockchain Ethereum. Recently, several users have been confused because of the discrepancies between the public keys depicted on their wallet “metamask”, and users received by calling “et_getencryppububluckey” RPC.
Problem: different public keys from the same private key
Let’s dive into the details of what is happening. When we use et_getencryptipublckekey, this requires a public encryption key to the address of the Ethereum account. However, this public key is calculated on the basis of a private key protected by metabout. Here’s the reason:
* Private key: The private key used to create an Ethereum wallet is exceptional for every person.
* Public key calculation:
When you receive your public key using Eth_Geartcryptickey, is not directly related to your personal key. Instead, it uses a different calculation method that creates a new set of key (public and private) based on common secrets between your wallet Metamask and Ethereum Blockchain.
* Total secret: This general secret is used to get a public key from a private key.
Solution: Restore ()
vs. et_getencryptipublckekey
You can use any of two methods to solve this problem:
-
Recesspublic ()
:
* To get a public key associated with a certain Ethereum address, you can call Recendalpublken ().
* This method provides a private key used by the MetamKK and allows you to take the public key.
- **
ET_GEVETIPLIKKEKEKEKEKEKEKE
* To get an Ethereum account encryption as before, you can use ET_GETENCRYPTACHEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKEKE.
* However, remember that it will return a different key set than if you have used Regentpublic ().
Code Example: Restore a public key using Metamask Recuepublckey ()
`Javascript
Const Web3 = Require (‘Web3’);
CONST METAMAK = New Web3 (New Web3.Providers.Httpprovider (‘
Metamask.Getaccouns (). Then (accounts => {
CONST PUBLICKEKE = Accounts [0] .Getpubluckey ();
// Get a private key using the Metavepublckey Method
Return Metamk.RECOVERPUBLIKKEKE (PUBLICKEKE);
});
`
Conclusion:
The difference between the public keys displayed in your Metamask purse and those obtained using RPC RPC RPC Eth_GettenCryspublken RPC calls can be solved using RegentPublic () or et_gettencriPubluckey. And the common secrets work together, you will be better ready to browse these complex interactions.
If you have any questions or you need to further explain this topic, don’t hesitate to ask!
ethereum between rate difficulty