Skip to content

Commit

Permalink
Fixed scrypt import in ESM build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Nov 20, 2019
1 parent e518151 commit b72ef27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src.ts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from "fs";
import { basename } from "path";

import { ethers } from "ethers";
import { scrypt } from "scrypt-js";
import * as scrypt from "scrypt-js";

import { getChoice, getPassword, getProgressBar } from "./prompt";

Expand Down Expand Up @@ -421,7 +421,7 @@ async function loadAccount(arg: string, plugin: Plugin, preventFile?: boolean):
let saltBytes = ethers.utils.arrayify(ethers.utils.HDNode.fromMnemonic(mnemonic).privateKey);

let progressBar = getProgressBar("Decrypting");
return scrypt(passwordBytes, saltBytes, (1 << 20), 8, 1, 32, progressBar).then((key) => {
return scrypt.scrypt(passwordBytes, saltBytes, (1 << 20), 8, 1, 32, progressBar).then((key) => {
const derivedPassword = ethers.utils.hexlify(key).substring(2);
const node = ethers.utils.HDNode.fromMnemonic(mnemonic, derivedPassword).derivePath(ethers.utils.defaultPath);
return new ethers.Wallet(node.privateKey, plugin.provider);
Expand Down
6 changes: 3 additions & 3 deletions packages/json-wallets/src.ts/keystore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

import aes from "aes-js";
import { scrypt } from "scrypt-js";
import * as scrypt from "scrypt-js";
import uuid from "uuid";

import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer";
Expand Down Expand Up @@ -148,7 +148,7 @@ export async function decrypt(json: string, password: Bytes | string, progressCa
throw new Error("unsupported key-derivation derived-key length");
}

const key = await scrypt(passwordBytes, salt, N, r, p, 64, progressCallback);
const key = await scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback);
//key = arrayify(key);

return getAccount(key);
Expand Down Expand Up @@ -260,7 +260,7 @@ export function encrypt(account: ExternallyOwnedAccount, password: Bytes | strin
// We take 64 bytes:
// - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix)
// - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet)
return scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then((key) => {
return scrypt.scrypt(passwordBytes, salt, N, r, p, 64, progressCallback).then((key) => {
key = arrayify(key);

// This will be used to encrypt the wallet (as per Web3 secret storage)
Expand Down

0 comments on commit b72ef27

Please sign in to comment.