Why is my Metamask address the same for different Ethereum Networks?
You might wonder why you have the same public address value for Ethereum and, say, Polygon Network in your MetaMask wallet?
First of all, that’s not a wallet bug. Metamask can have only Ethereum-compatible network addresses because it is an Ethereum wallet. To know why we can have the same address in two Ethereum-compatible networks, we need to understand how a public address is generated on the Ethereum Network.
To get a public address on the Ethereum network, the first step is to generate a random private key. After this, a public key is extracted from your private key using an algorithm (called ECDSA). Then, another algorithm (called keccak256) is applied to the hexadecimal form of your public key. Keep only the last 20 bytes of the result, which is your address on Ethereum, which always begins with ‘0x’.
Step 1: Generating the EC private key
Use OpenSSL ecparam command to generate an elliptic curve private key. Ethereum standard is to use the secp256k1 curve. The same curve is used by Bitcoin.
Step 2: Extract the public key from the private key
Pipe the above command with the ec command it will display both private and public parts in hexadecimal format
Step 3: Derive the Ethereum address from the public key
An Ethereum address is made of 20 bytes (40 hex characters long), it is commonly represented by adding the 0x prefix. In order to derive it, one should take the keccak-256 hash of the hexadecimal form of a public key, then keep only the last 20 bytes (aka get rid of the first 12 bytes).
The private-public key pair you have generated is most important here. It is not tied to the Ethereum network or any other network you use. It’s yours as long as you keep the private key safe. The transactions signed by you using your private key in one network is no way connected to another network where you have used your same private key again. So it does not matter that you have the same Ethereum public address you use in different Ethereum-compatible networks, and it is considered a good security practice.
Ethereum public address is just a string you use to identify your network address and as the name indicates is meant to be publicily shared.
Have a great week!