@polkadot/util-crypto#mnemonicToMiniSecret TypeScript Examples
The following examples show how to use
@polkadot/util-crypto#mnemonicToMiniSecret.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: bipWorker.ts From crust-apps with Apache License 2.0 | 6 votes |
ctx.onmessage = async ({ data: { pairType } }): Promise<void> => {
await cryptoWaitReady();
const seed = mnemonicGenerate();
const miniSecret = mnemonicToMiniSecret(seed);
const { publicKey } = pairType === 'sr25519'
? schnorrkelKeypairFromSeed(miniSecret)
: naclKeypairFromSeed(miniSecret);
ctx.postMessage({
publicKey,
seed
});
};
Example #2
Source File: Keyring.ts From gear-js with GNU General Public License v3.0 | 6 votes |
static async create(
name: string,
passphrase?: string,
): Promise<{
keyring: KeyringPair;
mnemonic: string;
seed: string;
json: KeyringPair$Json;
}> {
const mnemonic = mnemonicGenerate();
const seed = mnemonicToMiniSecret(mnemonic);
const keyring = await GearKeyring.fromSeed(seed, name);
return {
keyring,
mnemonic: mnemonic,
seed: u8aToHex(seed),
json: keyring.toJson(passphrase),
};
}
Example #3
Source File: Keyring.ts From gear-js with GNU General Public License v3.0 | 5 votes |
static generateSeed(mnemonic?: string): { seed: `0x${string}`; mnemonic: string } {
if (!mnemonic) {
mnemonic = mnemonicGenerate();
}
return { seed: u8aToHex(mnemonicToMiniSecret(mnemonic)), mnemonic };
}