Logo

dev-resources.site

for different kinds of informations.

How MetaMask Creates Accounts

Published at
4/13/2022
Categories
web3
ethereum
metamask
blockchain
Author
chandrapenugonda
Categories
4 categories in total
web3
open
ethereum
open
metamask
open
blockchain
open
Author
16 person written this
chandrapenugonda
open
How MetaMask Creates Accounts

How MetaMask Creates Accounts

  1. when you install MetaMask, you were shown a list of 12 words known as the Secret Recovery Phrase.

    • Note: The order of the words in the secret recovery phrase is important.
    • MetaMask uses a specification known as the BIP39 to generate these 12 words.
    • BIP39(Bitcoin Improvement Proposals) recommends use of a mnemonic phrase to recover accounts in the event your accounts are compromised or lost.MetaMask calls this mnemonic phrase as the Secret Recovery Phrase.
    • 12 words are chosen from a list of 2048 words.The complete list of 2048 words can be found from here
  2. Each word in the secret recovery phrase has a number associated with it. These numbers are used to form a seed integer, which is then used to create a set of public/private keys

seed integer generation

Generating the public/private key pair and the Ethereum address using seed interger

  1. a private key is generated using the seed integer using the SHA256 hash function
  2. public key is generated from private key using ECDSA(Elliptic Curve Signature) algorithm
  3. from the public key derived, compute a keccak256 hash
  4. from the keccak256 hash, take the last 20 bytes (which is 40 hexadecimals), prefix it with β€œ0x” and this is your Ethereum address.

Creating the Default Account

  1. With the public/private key pair created from the seed integer, MetaMask will now be able to create your first account.As explained, your first account is generated from the keccak256 hash.

  2. Internally, MetaMask encrypts your private key using the password that you supplied during the installation stage, and stores it in your browser’s data store. It does not store them on the cloud.

where do Metamask stores key

Creating Additional Accounts

  1. MetaMask makes use of the private key of the first account and hashes it to get the next private key.Using the newly created private key, the same procedure applies (as described earlier) to get the public key and subsequently the account address. And the next account is always the hash of the previous private key.

Multiple accounts from private key
Note:

  • This is the reason why your accounts can be recovered as long as you have your secret recovery phrase.
  • And this brings us to this very important point you have to know β€” protect your secret recovery phrase under lock and key! - Once you compromised your secret recovery phrase, your accounts can be accessed by anyone who has them. Needless to say, your cryptocurrencies will be gone in a heartbeat!

Credits: Wei-Meng Lee

metamask Article's
30 articles in total
Favicon
Your First Steps in Web3: A Simple Demo
Favicon
I hacked web3 wallet!
Favicon
Survival guide to DevConnect Istanbul MetaMask bounties
Favicon
How To Set a Custom Node URL in MetaMask - Tokenview
Favicon
Metamask Snaps
Favicon
Add Hearverse Chain in your Metamask
Favicon
How to Restore multiple Meta Mask Accounts: Tips and Tricks no one tells you !
Favicon
Fix : TokenService Error: ChainId 0x539 is not supported :(
Favicon
Sign in with Metamask using LiveView
Favicon
Introduction to Blockchain Wallet
Favicon
How to Load Unlimited Free Ethers to Metamask Wallet
Favicon
Signing data with MetaMask
Favicon
What are meta transactions, the EIP-712 standard, and how to sign a message with Metamask?
Favicon
Understanding MetaMask RPC methods and errors
Favicon
How to add Web3 Authentication using NEXT JS & MetaMask?
Favicon
What Is Web3?
Favicon
Dating site for developers
Favicon
plopchain
Favicon
How to use Gitcoin
Favicon
Signing message using Metamask in Flutter
Favicon
How to Add Polygon (MATIC) Network to MetaMask
Favicon
Create connect wallet button with React + Web3.js + Bootstrap
Favicon
Building with Flutter and Metamask
Favicon
React Hook for Add/Switch Chain to any Ethereum Network in MetaMask
Favicon
ETH Dubai 2022 Recap
Favicon
Tutorial: Connect to MetaMask using vanilla JavaScript
Favicon
Connect MetaMask wallet #JavaScript
Favicon
How MetaMask Creates Accounts
Favicon
Understand Metamask: the basics.
Favicon
How to setup a Metamask account.

Featured ones: