How to use the @polkadot/util-crypto.mnemonicToSeed function in @polkadot/util-crypto

To help you get started, we’ve selected a few @polkadot/util-crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / common / docs / examples / util-crypto / 03_mnemonic_generate_validate_bip39 / index.js View on Github external
async function main () {
  // Create mnemonic string for Alice using BIP39
  const mnemonicAlice = mnemonicGenerate();

  console.log(`Generated mnemonic: ${mnemonicAlice}`);

  // Validate the mnemic string that was generated
  const isValidMnemonic = mnemonicValidate(mnemonicAlice);

  console.log(`isValidMnemonic: ${isValidMnemonic}`);

  // Create valid seed from mnemonic as u8a and convert it to a string
  // FIXME - Replace with mnemonicToSeed once exposed
  const seedAlice = mnemonicToSeed(mnemonicAlice);

  // Generate new public/secret keypair for Alice from the supplied seed
  const { secretKey, publicKey } = naclKeypairFromSeed(seedAlice);

  // Encrypt, Sign and Validate the message. See Example 'Sign & Verify Message'
}
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / CreateNewAccountScreen.tsx View on Github external
generateAddressFromMnemonic (mnemonic: string): string {
    const { keyring } = this.context;
    const keypair = naclKeypairFromSeed(mnemonicToSeed(mnemonic));

    return keyring.encodeAddress(
      keypair.publicKey
    );
  }
github paritytech / substrate-light-ui / packages / light-apps / src / AddAccount / util.ts View on Github external
export function generateAddressFromMnemonic (keyring: Keyring, mnemonic: string): string {
  const keypair = naclKeypairFromSeed(mnemonicToSeed(mnemonic));

  return keyring.encodeAddress(
    keypair.publicKey
  );
}
github w3f / polkadot-deployer / lib / network / crypto.js View on Github external
function  generateSeed() {
  const mnemonic = generateValidMnemonic();

  const seedU8a = mnemonicToSeed(mnemonic);
  const seed = u8aToHex(seedU8a);

  return { seed, seedU8a, mnemonic};
}
github paritytech / substrate-light-ui / packages / light-apps / src / Onboarding / WelcomeScreen.tsx View on Github external
const confirmCreate = () => {
    const mnemonic = mnemonicGenerate();
    const keypair = naclKeypairFromSeed(mnemonicToSeed(mnemonic));

    keyring.encodeAddress(
      keypair.publicKey
    );

    let stashPair = keyring.createAccountMnemonic(mnemonic, stashPassword, { name: 'Stash', type: 'stash' });
    let controllerPair = keyring.createAccountMnemonic(mnemonic, controllerPassword, { name: 'Controller', type: 'controller' });

    const stashAddress = stashPair.address();
    const stashJson = stashPair.toJson(stashPassword);

    const controllerAddress = controllerPair.address();
    const controllerJson = stashPair.toJson(controllerPassword);

    const stashBlob = new Blob([JSON.stringify(stashJson)], { type: 'application/json; charset=utf-8' });
    const controllerBlob = new Blob([JSON.stringify(controllerJson)], { type: 'application/json; charset=utf-8' });