Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from @web3-js/scrypt-shim to scrypt-js #3536

Merged
merged 2 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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