How to use the @zilliqa-js/crypto.encryptPrivateKey function in @zilliqa-js/crypto

To help you get started, we’ve selected a few @zilliqa-js/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 Zilliqa / nucleus-wallet / src / encrypt.worker.ts View on Github external
const encrypt = async (event) => {
  try {
    const { passphrase } = event.data;
    const privateKey = schnorr.generatePrivateKey();
    const keystoreJSON = await encryptPrivateKey('pbkdf2', privateKey, passphrase);
    // @ts-ignore
    self.postMessage({ keystoreJSON, privateKey });
  } catch (error) {
    console.log(error);
    // @ts-ignore
    self.postMessage({ keystoreJSON: undefined, privateKey: undefined });
  }
};
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / account.ts View on Github external
async toFile(
    passphrase: string,
    kdf: 'pbkdf2' | 'scrypt' = 'scrypt',
  ): Promise {
    if (!passphrase || !passphrase.length) {
      throw new Error('Passphrase cannot have a length of 0');
    }

    const keystore = await zcrypto.encryptPrivateKey(
      kdf,
      this.privateKey,
      passphrase,
    );

    return keystore;
  }