Skip to content

Commit

Permalink
Merge branch '1.x' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke authored May 26, 2020
2 parents eff1a76 + 067ca10 commit 37781fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 336 deletions.
20 changes: 6 additions & 14 deletions packages/web3-eth-accounts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
},
"main": "src/index.js",
"dependencies": {
"@web3-js/scrypt-shim": "^0.1.0",
"crypto-browserify": "3.12.0",
"eth-lib": "^0.2.8",
"ethereumjs-common": "^1.3.2",
"ethereumjs-tx": "^2.1.1",
"scrypt-js": "^3.0.1",
"underscore": "1.9.1",
"uuid": "3.3.2",
"web3-core": "1.2.8",
Expand Down
6 changes: 3 additions & 3 deletions packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var Hash = require('eth-lib/lib/hash');
var RLP = require('eth-lib/lib/rlp');// jshint ignore:line
var Bytes = require('eth-lib/lib/bytes');// jshint ignore:line
var cryp = (typeof global === 'undefined') ? require('crypto-browserify') : require('crypto');
var scrypt = require('@web3-js/scrypt-shim');
var scrypt = require('scrypt-js');
var uuid = require('uuid');
var utils = require('web3-utils');
var helpers = require('web3-core-helpers');
Expand Down Expand Up @@ -366,7 +366,7 @@ Accounts.prototype.decrypt = function(v3Keystore, password, nonStrict) {
kdfparams = json.crypto.kdfparams;

// FIXME: support progress reporting callback
derivedKey = scrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
derivedKey = scrypt.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
} else if (json.crypto.kdf === 'pbkdf2') {
kdfparams = json.crypto.kdfparams;

Expand Down Expand Up @@ -416,7 +416,7 @@ Accounts.prototype.encrypt = function(privateKey, password, options) {
kdfparams.n = options.n || 8192; // 2048 4096 8192 16384
kdfparams.r = options.r || 8;
kdfparams.p = options.p || 1;
derivedKey = scrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
derivedKey = scrypt.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
} else {
throw new Error('Unsupported kdf');
}
Expand Down
Loading

0 comments on commit 37781fe

Please sign in to comment.