How to use the bip39.entropyToMnemonic function in bip39

To help you get started, we’ve selected a few bip39 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 cronoh / nanovault / src / app / components / configure-wallet / configure-wallet.component.ts View on Github external
async createNewWallet() {
    // If a wallet already exists, confirm that the seed is saved
    const confirmed = await this.confirmWalletOverwrite();
    if (!confirmed) return;

    const newSeed = this.walletService.createNewWallet();
    this.newWalletSeed = newSeed;
    this.newWalletMnemonic = bip.entropyToMnemonic(newSeed);

    // Split the seed up so we can show 4 per line
    const words = this.newWalletMnemonic.split(' ');
    const lines = [
      words.slice(0, 4),
      words.slice(4, 8),
      words.slice(8, 12),
      words.slice(12, 16),
      words.slice(16, 20),
      words.slice(20, 24),
    ];
    this.newWalletMnemonicLines = lines;

    this.activePanel = 3;
    this.notifications.sendSuccess(`Successfully created new wallet! Make sure to write down your seed!`);
  }
github iden3 / iden3js / src / key-container / local-storage-container.js View on Github external
generateKeySeed(masterSeed) {
    if (this.isUnlock()) {
      const root = hdkey.fromMasterSeed(masterSeed);
      const pathRoot = "m/44'/60'/0'";
      // Identity master generation
      const nodeId = root.derive(pathRoot);
      const privKey = nodeId._privateKey;
      const keySeed = bip39.entropyToMnemonic(privKey);
      const keySeedEncrypted = kcUtils.encrypt(this.encryptionKey, keySeed);
      const pathKey = Buffer.alloc(4);
      pathKey.writeUInt32BE(0);
      const pathKeySeedEncrypted = kcUtils.encrypt(this.encryptionKey, utils.bytesToHex(pathKey));
      this.db.insert(`${this.prefix}keySeed`, JSON.stringify({ keySeedEncrypted, pathKeySeedEncrypted }));
      return true;
    }
    return false;
  }
github BlueWallet / BlueWallet / class / hd-segwit-p2sh-wallet.js View on Github external
return crypto.randomBytes(32, (err, buf) => { // eslint-disable-line
          if (err) throw err;
          that.secret = bip39.entropyToMnemonic(buf.toString('hex'));
          resolve();
        });
      }
github airgap-it / airgap-vault / src / app / models / BIP39Signer.ts View on Github external
const secretDigester: Hasher = sha3_256.create()

    // TODO check if mnemoinc or secret
    const seed: string = bip39.mnemonicToEntropy(secret)
    secretDigester.update(seed)

    const shares = secretJS.share(seed + secretDigester.hex().slice(0, this.checkSumLength), numberOfShares, threshold)
    const calculatedShares = []
    for (let i = 0; i < shares.length; i++) {
      const paddedShare = shares[i].concat(
        Array(29)
          .fill(0)
          .map(() => this.getRandomIntInclusive(0, 9))
          .join('')
      )
      calculatedShares[i] = `${bip39.entropyToMnemonic(paddedShare.slice(0, 64))} ${bip39.entropyToMnemonic(paddedShare.slice(64, 128))}`
    }

    return calculatedShares
  }
github airgap-it / airgap-vault / src / models / BIP39Signer.ts View on Github external
entropyToMnemonic(entropy: string): string {
    return bip39.entropyToMnemonic(entropy)
  }
github GetScatter / ScatterDesktop / electron / services / wallet.js View on Github external
const passwordToSeed = async password => {
	const hash = await hashPassword(password);
	let mnemonic = bip39.entropyToMnemonic(hash);
	return bip39.mnemonicToSeedHex(mnemonic);
}
github BlueWallet / BlueWallet / class / hd-segwit-bech32-wallet.js View on Github external
RNRandomBytes.randomBytes(32, (err, bytes) => {
        if (err) throw new Error(err);
        let b = Buffer.from(bytes, 'base64').toString('hex');
        that.secret = bip39.entropyToMnemonic(b);
        resolve();
      });
    });
github vitelabs / vite.js / packages / vitejs / es5 / hdAddr / index.js View on Github external
function getMnemonicFromEntropy(entropy, lang) {
    if (lang === void 0) { lang = type_1.LangList.english; }
    var err = vitejs_utils_1.checkParams({ entropy: entropy }, ['entropy']);
    if (err) {
        throw new Error(err.message);
    }
    return bip39.entropyToMnemonic(entropy, getWordList(lang));
}
exports.getMnemonicFromEntropy = getMnemonicFromEntropy;
github vacuumlabs / cardano-crypto.js / index.js View on Github external
const input = Buffer.from(bip39.mnemonicToEntropy(mnemonic), 'hex')
  const saltLength = 8

  if (saltLength >= input.length) {
    throw Error('unscrambleStrings: Input is too short')
  }

  const outputLength = input.length - saltLength

  const output = await pbkdf2(passphrase, input.slice(0, saltLength), 10000, outputLength, 'sha512')

  for (let i = 0; i < outputLength; i++) {
    output[i] = output[i] ^ input[saltLength + i]
  }

  return bip39.entropyToMnemonic(output)
}
github ontio / ontology-ts-sdk / src / core.ts View on Github external
export function generateMnemonic(size: number = 16): string {
    const random = ab2hexstring(generateRandomArray(size));
    return bip39.entropyToMnemonic(random);
}