diff --git a/.gitignore b/.gitignore index 9b6fa50..a47e66f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules build dist .DS_Store -yarn-error.log \ No newline at end of file +yarn-error.log +.vscode \ No newline at end of file diff --git a/patches/web3-eth-accounts+1.7.4.patch b/patches/web3-eth-accounts+1.7.4.patch index 6aa68a7..1fdb2e7 100644 --- a/patches/web3-eth-accounts+1.7.4.patch +++ b/patches/web3-eth-accounts+1.7.4.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/web3-eth-accounts/lib/index.js b/node_modules/web3-eth-accounts/lib/index.js -index a176dd9..de56ed8 100644 +index a176dd9..1a26ff6 100644 --- a/node_modules/web3-eth-accounts/lib/index.js +++ b/node_modules/web3-eth-accounts/lib/index.js @@ -23,7 +23,7 @@ @@ -11,40 +11,33 @@ index a176dd9..de56ed8 100644 var scrypt = require('scrypt-js'); var uuid = require('uuid'); var utils = require('web3-utils'); -@@ -420,7 +420,14 @@ Accounts.prototype.decrypt = function (v3Keystore, password, nonStrict) { +@@ -420,7 +420,11 @@ Accounts.prototype.decrypt = function (v3Keystore, password, nonStrict) { if (json.crypto.kdf === 'scrypt') { kdfparams = json.crypto.kdfparams; // FIXME: support progress reporting callback - derivedKey = scrypt.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); -+ var start = Date.now(); -+ + if (window.jsb && window.jsb.jcCryptoScrypt) { + derivedKey = jsb.jcCryptoScrypt(password, kdfparams.salt, kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); + } else { + derivedKey = scrypt.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); + } -+ console.log('scrypt encrypt cost time: ' + (Date.now() - start)/1000); } else if (json.crypto.kdf === 'pbkdf2') { kdfparams = json.crypto.kdfparams; -@@ -463,7 +470,15 @@ Accounts.prototype.encrypt = function (privateKey, password, options) { +@@ -463,7 +467,11 @@ 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.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); -+ var start = Date.now(); -+ + if (window.jsb && window.jsb.jcCryptoScrypt) { + derivedKey = jsb.jcCryptoScrypt(password, kdfparams.salt, kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); + } else { + derivedKey = scrypt.syncScrypt(Buffer.from(password), Buffer.from(kdfparams.salt, 'hex'), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen); + } -+ -+ console.log('scrypt encrypt cost time: ' + (Date.now() - start)/1000); } else { throw new Error('Unsupported kdf'); -@@ -621,6 +636,9 @@ if (!storageAvailable('localStorage')) { +@@ -621,6 +629,9 @@ if (!storageAvailable('localStorage')) { */ function storageAvailable(type) { var storage;