jcc_wallet 4.0.7 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,7 +118,7 @@ exports.plugin = {
118
118
  if (!exports.plugin.isValidSecret(key)) {
119
119
  return null;
120
120
  }
121
- const publicKey = secp256k1_js_1.secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(key), "hex")).toHex(false);
121
+ const publicKey = secp256k1_js_1.secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(key), "hex")).toHex(true);
122
122
  return {
123
123
  privateKey: key,
124
124
  publicKey: publicKey.substring(2)
package/lib/util/index.js CHANGED
@@ -10,6 +10,17 @@ const utils_js_1 = require("@noble/hashes/utils.js");
10
10
  const scrypt_js_1 = require("@noble/hashes/scrypt.js");
11
11
  const constant_1 = require("../constant");
12
12
  const is_plain_object_1 = __importDefault(require("is-plain-object"));
13
+ // Constant-time buffer comparison to prevent MAC timing attacks
14
+ function equalConstTime(b1, b2) {
15
+ if (b1.length !== b2.length) {
16
+ return false;
17
+ }
18
+ let res = 0;
19
+ for (let i = 0; i < b1.length; i++) {
20
+ res |= b1[i] ^ b2[i];
21
+ }
22
+ return res === 0;
23
+ }
13
24
  const isEmptyPlainObject = (obj) => {
14
25
  const isPlain = (0, is_plain_object_1.default)(obj);
15
26
  if (!isPlain) {
@@ -45,7 +56,7 @@ const decrypt = async (password, encryptData) => {
45
56
  .create()
46
57
  .update(Buffer.concat([derivedKey.slice(16, 32), ciphertext]))
47
58
  .digest();
48
- if (Buffer.from(mac).toString("hex") !== encryptData.mac) {
59
+ if (!equalConstTime(Buffer.from(mac), Buffer.from(encryptData.mac, "hex"))) {
49
60
  throw new Error(constant_1.PASSWORD_IS_WRONG);
50
61
  }
51
62
  const buf = await (0, aes_1.decrypt)(ciphertext, derivedKey.slice(0, 16), iv, "aes-128-ctr");
@@ -64,7 +75,7 @@ const encrypt = async (password, data, opts) => {
64
75
  const iv = opts.iv || Buffer.from((0, utils_js_1.randomBytes)(16)).toString("hex");
65
76
  const kdfparams = {
66
77
  dklen: opts.dklen || 32,
67
- n: opts.n || 4096,
78
+ n: opts.n || 16384,
68
79
  p: opts.p || 1,
69
80
  r: opts.r || 8,
70
81
  salt: opts.salt || Buffer.from((0, utils_js_1.randomBytes)(32)).toString("hex")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc_wallet",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "description": "Toolkit of wallet to manage multiple chains & support multiple keystores for each chain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -75,14 +75,14 @@
75
75
  "karma-mocha": "^2.0.1",
76
76
  "karma-webpack": "^5.0.1",
77
77
  "mocha": "^10.2.0",
78
- "node-polyfill-webpack-plugin": "^4.0.0",
78
+ "node-polyfill-webpack-plugin": "^4.1.0",
79
79
  "prettier": "^1.19.1",
80
80
  "pretty-quick": "^2.0.1",
81
81
  "sinon": "^17.0.1",
82
82
  "ts-loader": "^9.5.1",
83
83
  "typescript": "5.7.2",
84
84
  "typescript-eslint": "^8.48.1",
85
- "webpack": "^5.89.0",
85
+ "webpack": "^5.106.2",
86
86
  "webpack-bundle-analyzer": "^4.10.1",
87
87
  "webpack-cli": "^5.1.4"
88
88
  },
@@ -96,5 +96,31 @@
96
96
  "lockr": "^0.8.5"
97
97
  },
98
98
  "sideEffects": false,
99
- "packageManager": "yarn@4.0.0-rc.48"
99
+ "packageManager": "yarn@4.0.0-rc.48",
100
+ "overrides": {
101
+ "elliptic": "6.6.1",
102
+ "flatted": "3.4.2",
103
+ "lodash": "4.18.1",
104
+ "follow-redirects": "1.16.0",
105
+ "qs": "6.15.1",
106
+ "picomatch": "4.0.4",
107
+ "socket.io-parser": "4.2.6",
108
+ "serialize-javascript": "7.0.5",
109
+ "babel-plugin-istanbul": "8.0.2",
110
+ "bn.js": "5.2.3",
111
+ "diff": "5.2.2"
112
+ },
113
+ "resolutions": {
114
+ "elliptic": "6.6.1",
115
+ "flatted": "3.4.2",
116
+ "lodash": "4.18.1",
117
+ "follow-redirects": "1.16.0",
118
+ "qs": "6.15.1",
119
+ "picomatch": "4.0.4",
120
+ "socket.io-parser": "4.2.6",
121
+ "serialize-javascript": "7.0.5",
122
+ "babel-plugin-istanbul": "8.0.2",
123
+ "bn.js": "5.2.3",
124
+ "diff": "5.2.2"
125
+ }
100
126
  }