Hi , i am trying to study the react native code and playing with it. I need to know the exact files where the seed phrase and private key generation is happening in the code . I want to understand the code for the scenario when user logs in and clicks on create a new wallet.
Hello @user1289 !
Welcome to MetaMask community !
Under the hood of generating a private key is the BIP39 standard.
You can see it briefly here:
MetaMask uses BIP39 standard for seed phrase.
This BIP describes the implementation of a mnemonic code or mnemonic sentence – a group of easy to remember words – for the generation of deterministic wallets.
It consists of two parts: generating the mnemonic and converting it into a binary seed.
Theoretically, you can generate the mnemonic yourself and pass it as a parameter to:
const HDWalletProvider = require("@truffle/hdwallet-provider");
let provider = new HDWalletProvider({
mnemonic: {…
Also you can look at the library:
@metamask/bip39
But be careful!
This is a temporary fork of the bip39 package created by the MetaMask team. Please do not use this package for other projects, use bip39 directly instead. We are not interested in maintaining this long-term. We will abandon this as soon as we find a suitable replacement, and will not be accepting community issues or PRs.
Using it you can generate a phrase automatically:
// Generate a random mnemonic (uses crypto.randomBytes …
4 Likes
system
Closed
May 13, 2023, 2:16pm
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.