How to use the @zilliqa-js/crypto.decryptPrivateKey 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 / decrypt.worker.ts View on Github external
const decrypt = async (event) => {
  try {
    const { passphrase, keystoreV3 } = event.data;
    const privateKey = await decryptPrivateKey(passphrase, keystoreV3);
    // @ts-ignore
    self.postMessage({ privateKey });
  } catch (error) {
    console.log(error);
    // @ts-ignore
    self.postMessage({ privateKey: undefined });
  }
};
github Zilliqa / Zilliqa-JavaScript-Library / packages / zilliqa-js-account / src / account.ts View on Github external
static async fromFile(file: string, passphrase: string): Promise {
    try {
      const keystore = JSON.parse(file);
      const privateKey = await zcrypto.decryptPrivateKey(passphrase, keystore);

      return new Account(privateKey);
    } catch (err) {
      throw new Error(`Could not decrypt keystore file.`);
    }
  }