jcc_wallet 4.0.2 → 4.0.4

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.
package/lib/eccrypto.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  export declare const encrypt: (publicKeyTo: any, msg: any, opts?: any) => Promise<{
7
7
  iv: any;
8
8
  ephemPublicKey: any;
9
- ciphertext: Uint8Array;
10
- mac: Buffer;
9
+ ciphertext: Uint8Array<ArrayBufferLike>;
10
+ mac: Buffer<ArrayBuffer>;
11
11
  }>;
12
- export declare const decrypt: (privateKey: any, opts: any) => Promise<Uint8Array>;
12
+ export declare const decrypt: (privateKey: any, opts: any) => Promise<Uint8Array<ArrayBufferLike>>;
package/lib/eccrypto.js CHANGED
@@ -8,13 +8,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.decrypt = exports.encrypt = void 0;
9
9
  const EC_GROUP_ORDER = Buffer.from("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", "hex");
10
10
  const ZERO32 = Buffer.alloc(32, 0);
11
- const utils_1 = require("@noble/hashes/utils");
12
- const sha512_1 = require("@noble/hashes/sha512");
13
- const hmac_1 = require("@noble/hashes/hmac");
14
- const sha2_1 = require("@noble/hashes/sha2");
11
+ const utils_js_1 = require("@noble/hashes/utils.js");
12
+ const hmac_js_1 = require("@noble/hashes/hmac.js");
13
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
15
14
  const aes_1 = require("ethereum-cryptography/aes");
16
- const secp256k1_1 = require("@noble/curves/secp256k1");
17
- const Point = secp256k1_1.secp256k1.ProjectivePoint;
15
+ const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
16
+ const Point = secp256k1_js_1.secp256k1.ProjectivePoint;
18
17
  function isScalar(x) {
19
18
  return Buffer.isBuffer(x) && x.length === 32;
20
19
  }
@@ -31,7 +30,7 @@ function assert(condition, message) {
31
30
  }
32
31
  }
33
32
  function sha512(msg) {
34
- return sha512_1.sha512.create()
33
+ return sha2_js_1.sha512.create()
35
34
  .update(msg)
36
35
  .digest();
37
36
  }
@@ -43,8 +42,8 @@ async function aes256CbcDecrypt(iv, key, ciphertext) {
43
42
  return await (0, aes_1.decrypt)(ciphertext, key, iv, "aes-256-cbc");
44
43
  }
45
44
  function hmacSha256(key, msg) {
46
- return hmac_1.hmac
47
- .create(sha2_1.sha256, key)
45
+ return hmac_js_1.hmac
46
+ .create(sha2_js_1.sha256, key)
48
47
  .update(msg)
49
48
  .digest();
50
49
  }
@@ -68,7 +67,7 @@ const derive = async (privateKeyA, publicKeyB) => {
68
67
  return new Promise((resolve) => {
69
68
  assert(privateKeyA.length === 32, "Bad private key");
70
69
  assert(isValidPrivateKey(privateKeyA), "Bad private key");
71
- resolve(secp256k1_1.secp256k1.getSharedSecret(privateKeyA, publicKeyB));
70
+ resolve(secp256k1_js_1.secp256k1.getSharedSecret(privateKeyA, publicKeyB));
72
71
  });
73
72
  };
74
73
  const encrypt = (publicKeyTo, msg, opts) => {
@@ -76,16 +75,16 @@ const encrypt = (publicKeyTo, msg, opts) => {
76
75
  // Tmp variable to save context from flat promises;
77
76
  let ephemPublicKey;
78
77
  return new Promise(function (resolve) {
79
- let ephemPrivateKey = opts.ephemPrivateKey || Buffer.from((0, utils_1.randomBytes)(32));
78
+ let ephemPrivateKey = opts.ephemPrivateKey || Buffer.from((0, utils_js_1.randomBytes)(32));
80
79
  // There is a very unlikely possibility that it is not a valid key
81
80
  while (!isValidPrivateKey(ephemPrivateKey)) {
82
- ephemPrivateKey = opts.ephemPrivateKey || Buffer.from((0, utils_1.randomBytes)(32));
81
+ ephemPrivateKey = opts.ephemPrivateKey || Buffer.from((0, utils_js_1.randomBytes)(32));
83
82
  }
84
83
  ephemPublicKey = getPublic(ephemPrivateKey);
85
84
  resolve(derive(ephemPrivateKey, publicKeyTo));
86
85
  }).then(async function (Px) {
87
86
  const hash = sha512(Px);
88
- const iv = opts.iv || (0, utils_1.randomBytes)(16);
87
+ const iv = opts.iv || (0, utils_js_1.randomBytes)(16);
89
88
  const encryptionKey = hash.slice(0, 32);
90
89
  const macKey = hash.slice(32);
91
90
  const ciphertext = await aes256CbcEncrypt(iv, encryptionKey, msg);
@@ -13,7 +13,9 @@ declare enum BIP44Chain {
13
13
  CALL = 2147484281,
14
14
  BVCADT = 2399141888,
15
15
  STREAM = 2399141889,
16
- BIZAIN = 2399141890
16
+ BIZAIN = 2399141890,
17
+ BASE = 2147492101,
18
+ ARB1 = 2147492649
17
19
  }
18
20
  /**
19
21
  * get bip44 chain constant
@@ -24,6 +24,8 @@ var BIP44Chain;
24
24
  BIP44Chain[BIP44Chain["BVCADT"] = 2399141888] = "BVCADT";
25
25
  BIP44Chain[BIP44Chain["STREAM"] = 2399141889] = "STREAM";
26
26
  BIP44Chain[BIP44Chain["BIZAIN"] = 2399141890] = "BIZAIN";
27
+ BIP44Chain[BIP44Chain["BASE"] = 2147492101] = "BASE";
28
+ BIP44Chain[BIP44Chain["ARB1"] = 2147492649] = "ARB1";
27
29
  })(BIP44Chain || (exports.BIP44Chain = BIP44Chain = {}));
28
30
  /**
29
31
  * get bip44 chain constant
@@ -50,6 +52,8 @@ const BIP44ChainMap = new Map([
50
52
  [BIP44Chain.CALL, "call"],
51
53
  [BIP44Chain.BVCADT, "bvcadt"],
52
54
  [BIP44Chain.STREAM, "stream"],
53
- [BIP44Chain.BIZAIN, "bizain"]
55
+ [BIP44Chain.BIZAIN, "bizain"],
56
+ [BIP44Chain.BASE, "base"],
57
+ [BIP44Chain.ARB1, "arb1"]
54
58
  ]);
55
59
  exports.BIP44ChainMap = BIP44ChainMap;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.plugin = void 0;
4
- const sha256_1 = require("@noble/hashes/sha256");
4
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
5
5
  const PublicKey_1 = require("../minify-eosjs/PublicKey");
6
6
  const PrivateKey_1 = require("../minify-eosjs/PrivateKey");
7
7
  const Signature_1 = require("../minify-eosjs/Signature");
@@ -41,7 +41,7 @@ exports.plugin = {
41
41
  const pk = PublicKey_1.PublicKey.fromString(address);
42
42
  return pk.isValid();
43
43
  }
44
- catch (_) {
44
+ catch (_a) {
45
45
  return false;
46
46
  }
47
47
  },
@@ -50,12 +50,12 @@ exports.plugin = {
50
50
  const eosPrivateKey = exports.plugin.privateKeyToLegacyString(secret);
51
51
  return PrivateKey_1.PrivateKey.fromString(eosPrivateKey).isValid();
52
52
  }
53
- catch (_) {
53
+ catch (_a) {
54
54
  return false;
55
55
  }
56
56
  },
57
57
  hash(message) {
58
- return Buffer.from(sha256_1.sha256
58
+ return Buffer.from(sha2_js_1.sha256
59
59
  .create()
60
60
  .update(message)
61
61
  .digest()).toString("hex");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.plugin = void 0;
4
- const secp256k1_1 = require("@noble/curves/secp256k1");
4
+ const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
5
5
  const keccak_js_1 = require("ethereum-cryptography/keccak.js");
6
6
  const bytes_1 = require("../minify-ethereumjs-util/bytes");
7
7
  const internal_1 = require("../minify-ethereumjs-util/internal");
@@ -9,7 +9,7 @@ const signature_1 = require("../minify-ethereumjs-util/signature");
9
9
  const account_1 = require("../minify-ethereumjs-util/account");
10
10
  const util_1 = require("../util");
11
11
  const constant_1 = require("../constant");
12
- const utils_1 = require("@noble/hashes/utils");
12
+ const utils_js_1 = require("@noble/hashes/utils.js");
13
13
  const isObject = (obj) => {
14
14
  return Object.prototype.toString.call(obj) === "[object Object]";
15
15
  };
@@ -39,14 +39,14 @@ exports.plugin = {
39
39
  if (!exports.plugin.isValidSecret(secret)) {
40
40
  return null;
41
41
  }
42
- const pk = secp256k1_1.secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(secret), "hex")).toHex(false);
42
+ const pk = secp256k1_js_1.secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(secret), "hex")).toHex(false);
43
43
  return (0, bytes_1.bytesToHex)((0, account_1.pubToAddress)(Buffer.from(pk.substring(2), "hex")));
44
44
  },
45
45
  isValidSecret(secret) {
46
46
  try {
47
- return secp256k1_1.secp256k1.utils.isValidPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(secret), "hex"));
47
+ return secp256k1_js_1.secp256k1.utils.isValidPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(secret), "hex"));
48
48
  }
49
- catch (_) {
49
+ catch (_a) {
50
50
  return false;
51
51
  }
52
52
  },
@@ -108,7 +108,7 @@ exports.plugin = {
108
108
  return buf.toString("hex");
109
109
  },
110
110
  createWallet() {
111
- const priv = (0, utils_1.randomBytes)(32);
111
+ const priv = (0, utils_js_1.randomBytes)(32);
112
112
  const address = exports.plugin.getAddress((0, bytes_1.bytesToHex)(priv));
113
113
  return { address, secret: (0, bytes_1.bytesToHex)(priv) };
114
114
  }
package/lib/hd/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.HDWallet = exports.getBIP44Chain = exports.BIP44ChainMap = exports.BIP44Chain = void 0;
27
37
  const minify_swtc_keypair_1 = require("../minify-swtc-keypair");
package/lib/hd/plugins.js CHANGED
@@ -23,6 +23,7 @@ const pluginMap = {
23
23
  ethereum: ethereum_plugin_1.plugin,
24
24
  bsc: ethereum_plugin_2.plugin,
25
25
  heco: ethereum_plugin_3.plugin,
26
+ moac: ethereum_plugin_1.plugin,
26
27
  polygon: ethereum_plugin_4.plugin,
27
28
  tron: tron_plugin_1.plugin,
28
29
  eos: eos_plugin_1.plugin,
@@ -31,7 +32,9 @@ const pluginMap = {
31
32
  ripple: exports.rippleWallet,
32
33
  stream: exports.stmWallet,
33
34
  bizain: exports.bizainWallet,
34
- jingtum: exports.jtWallet
35
+ jingtum: exports.jtWallet,
36
+ base: ethereum_plugin_1.plugin,
37
+ arb1: ethereum_plugin_1.plugin
35
38
  };
36
39
  function getPluginByType(type) {
37
40
  return pluginMap[type];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SWTCPlugin = void 0;
4
4
  const minify_swtc_keypair_1 = require("../minify-swtc-keypair");
5
- const utils_1 = require("@noble/curves/abstract/utils");
5
+ const utils_js_1 = require("@noble/curves/abstract/utils.js");
6
6
  const SWTCPlugin = (alphabet) => {
7
7
  const Wallet = (0, minify_swtc_keypair_1.Factory)(alphabet);
8
8
  const isValidAddress = (address) => {
@@ -12,7 +12,7 @@ const SWTCPlugin = (alphabet) => {
12
12
  return Wallet.isValidSecret(secret);
13
13
  };
14
14
  const hash = (message) => {
15
- return (0, utils_1.bytesToHex)(Wallet.hash(message)).toUpperCase();
15
+ return (0, utils_js_1.bytesToHex)(Wallet.hash(message)).toUpperCase();
16
16
  };
17
17
  const sign = (message, privateKey) => {
18
18
  return Wallet.sign(message, privateKey);
@@ -32,7 +32,7 @@ const SWTCPlugin = (alphabet) => {
32
32
  }
33
33
  return null;
34
34
  }
35
- catch (_) {
35
+ catch (_a) {
36
36
  return null;
37
37
  }
38
38
  };
@@ -46,7 +46,7 @@ const SWTCPlugin = (alphabet) => {
46
46
  }
47
47
  return Wallet.verify(message, signature, keypair.publicKey);
48
48
  }
49
- catch (_) {
49
+ catch (_a) {
50
50
  return false;
51
51
  }
52
52
  };
@@ -58,7 +58,7 @@ const SWTCPlugin = (alphabet) => {
58
58
  const wallet = Wallet.fromSecret(secret);
59
59
  return wallet.address;
60
60
  }
61
- catch (_) {
61
+ catch (_a) {
62
62
  return null;
63
63
  }
64
64
  };
@@ -66,7 +66,7 @@ const SWTCPlugin = (alphabet) => {
66
66
  try {
67
67
  return Wallet.generate(opt);
68
68
  }
69
- catch (_) {
69
+ catch (_a) {
70
70
  return null;
71
71
  }
72
72
  };
@@ -35,7 +35,7 @@ exports.plugin = {
35
35
  const address = (0, crypto_1.getBase58CheckAddress)(comCddressBytes);
36
36
  return exports.plugin.isValidAddress(address);
37
37
  }
38
- catch (_) {
38
+ catch (_a) {
39
39
  return false;
40
40
  }
41
41
  },
package/lib/index.js CHANGED
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
35
35
  }) : function(o, v) {
36
36
  o["default"] = v;
37
37
  });
38
- var __importStar = (this && this.__importStar) || function (mod) {
39
- if (mod && mod.__esModule) return mod;
40
- var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
- __setModuleDefault(result, mod);
43
- return result;
44
- };
38
+ var __importStar = (this && this.__importStar) || (function () {
39
+ var ownKeys = function(o) {
40
+ ownKeys = Object.getOwnPropertyNames || function (o) {
41
+ var ar = [];
42
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
43
+ return ar;
44
+ };
45
+ return ownKeys(o);
46
+ };
47
+ return function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
51
+ __setModuleDefault(result, mod);
52
+ return result;
53
+ };
54
+ })();
45
55
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
46
56
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
47
57
  };
@@ -15,19 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  const clone_deep_1 = __importDefault(require("clone-deep"));
30
- const sha256_1 = require("@noble/hashes/sha256");
40
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
31
41
  const eccrypto = __importStar(require("./eccrypto"));
32
42
  const util_1 = require("./util");
33
43
  const lockr_1 = __importDefault(require("lockr"));
@@ -73,7 +83,7 @@ class JingchangWallet {
73
83
  const walletsNotEmpty = !(0, util_1.isEmptyPlainObject)(wallet) && Array.isArray(wallet.wallets) && wallet.wallets.length > 0;
74
84
  return Boolean(walletsNotEmpty && wallet.contact && wallet.id && wallet.version);
75
85
  }
76
- catch (error) {
86
+ catch (_a) {
77
87
  return false;
78
88
  }
79
89
  }
@@ -274,7 +284,7 @@ class JingchangWallet {
274
284
  const wallet = this.findWallet((w) => w.type === type && w.default);
275
285
  return !(0, util_1.isEmptyPlainObject)(wallet);
276
286
  }
277
- catch (error) {
287
+ catch (_a) {
278
288
  return false;
279
289
  }
280
290
  }
@@ -540,7 +550,7 @@ class JingchangWallet {
540
550
  }
541
551
  JingchangWallet.version = "1.0";
542
552
  JingchangWallet._name = "wallets";
543
- JingchangWallet._walletID = Buffer.from(sha256_1.sha256
553
+ JingchangWallet._walletID = Buffer.from(sha2_js_1.sha256
544
554
  .create()
545
555
  .update(JingchangWallet._name.toLowerCase())
546
556
  .digest()).toString("hex");
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import BN from "bn.js";
7
7
  import { Key, KeyType } from "./eosjs-numeric";
8
- import { ProjPointType, CurveFn } from "@noble/curves/abstract/weierstrass";
8
+ import { ProjPointType, CurveFn } from "@noble/curves/abstract/weierstrass.js";
9
9
  import { PublicKey, Signature } from "./eosjs-key-conversions";
10
10
  /** Represents/stores a private key and provides easy conversion for use with `elliptic` lib */
11
11
  export declare class PrivateKey {
@@ -4,7 +4,7 @@
4
4
  * rewrite curves
5
5
  */
6
6
  import { Key, KeyType } from "./eosjs-numeric";
7
- import { ProjPointType, CurveFn } from "@noble/curves/abstract/weierstrass";
7
+ import { ProjPointType, CurveFn } from "@noble/curves/abstract/weierstrass.js";
8
8
  /** Represents/stores a public key and provides easy conversion for use with `elliptic` lib */
9
9
  export declare class PublicKey {
10
10
  private key;
@@ -6,7 +6,7 @@
6
6
  import { Key, KeyType } from "./eosjs-numeric";
7
7
  import { PublicKey } from "./eosjs-key-conversions";
8
8
  import { BN } from "bn.js";
9
- import { CurveFn, SignatureType, RecoveredSignatureType } from "@noble/curves/abstract/weierstrass";
9
+ import { CurveFn, SignatureType, RecoveredSignatureType } from "@noble/curves/abstract/weierstrass.js";
10
10
  /** Represents/stores a Signature and provides easy conversion for use with `elliptic` lib */
11
11
  export declare class Signature {
12
12
  private signature;
@@ -7,6 +7,6 @@ import { KeyType } from "./eosjs-numeric";
7
7
  export { PrivateKey } from "./PrivateKey";
8
8
  export { PublicKey } from "./PublicKey";
9
9
  export { Signature } from "./Signature";
10
- import { CurveFn } from "@noble/curves/abstract/weierstrass";
10
+ import { CurveFn } from "@noble/curves/abstract/weierstrass.js";
11
11
  /** Construct the elliptic curve object based on key type */
12
12
  export declare const constructElliptic: (type: KeyType) => CurveFn;
@@ -13,13 +13,13 @@ var PublicKey_1 = require("./PublicKey");
13
13
  Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return PublicKey_1.PublicKey; } });
14
14
  var Signature_1 = require("./Signature");
15
15
  Object.defineProperty(exports, "Signature", { enumerable: true, get: function () { return Signature_1.Signature; } });
16
- const secp256k1_1 = require("@noble/curves/secp256k1");
17
- const p256_1 = require("@noble/curves/p256");
16
+ const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
17
+ const p256_js_1 = require("@noble/curves/p256.js");
18
18
  /** Construct the elliptic curve object based on key type */
19
19
  const constructElliptic = (type) => {
20
20
  if (type === eosjs_numeric_1.KeyType.k1) {
21
- return secp256k1_1.secp256k1;
21
+ return secp256k1_js_1.secp256k1;
22
22
  }
23
- return p256_1.p256;
23
+ return p256_js_1.p256;
24
24
  };
25
25
  exports.constructElliptic = constructElliptic;
@@ -7,8 +7,8 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.privateKeyToString = exports.privateKeyToLegacyString = exports.signatureToString = exports.stringToSignature = exports.stringToPrivateKey = exports.publicKeyToLegacyString = exports.stringToPublicKey = exports.signatureDataSize = exports.privateKeyDataSize = exports.publicKeyDataSize = exports.KeyType = exports.binaryToBase58 = exports.base58ToBinary = void 0;
10
- const ripemd160_1 = require("@noble/hashes/ripemd160");
11
- const sha256_1 = require("@noble/hashes/sha256");
10
+ const legacy_js_1 = require("@noble/hashes/legacy.js");
11
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
12
12
  const base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
13
13
  const create_base58_map = () => {
14
14
  const base58M = Array(256).fill(-1);
@@ -125,12 +125,12 @@ const digestSuffixRipemd160 = (data, suffix) => {
125
125
  for (let i = 0; i < suffix.length; ++i) {
126
126
  d[data.length + i] = suffix.charCodeAt(i);
127
127
  }
128
- return (0, ripemd160_1.ripemd160)(d);
128
+ return (0, legacy_js_1.ripemd160)(d);
129
129
  };
130
130
  const stringToKey = (s, type, size, suffix) => {
131
131
  const whole = (0, exports.base58ToBinary)(size ? size + 4 : 0, s);
132
132
  const result = { type, data: new Uint8Array(whole.buffer, 0, whole.length - 4) };
133
- const digest = new Uint8Array(digestSuffixRipemd160(result.data, suffix));
133
+ const digest = digestSuffixRipemd160(result.data, suffix);
134
134
  if (digest[0] !== whole[whole.length - 4] ||
135
135
  digest[1] !== whole[whole.length - 3] ||
136
136
  digest[2] !== whole[whole.length - 2] ||
@@ -140,7 +140,7 @@ const stringToKey = (s, type, size, suffix) => {
140
140
  return result;
141
141
  };
142
142
  const keyToString = (key, suffix, prefix) => {
143
- const digest = new Uint8Array(digestSuffixRipemd160(key.data, suffix));
143
+ const digest = digestSuffixRipemd160(key.data, suffix);
144
144
  const whole = new Uint8Array(key.data.length + 4);
145
145
  for (let i = 0; i < key.data.length; ++i) {
146
146
  whole[i] = key.data[i];
@@ -161,7 +161,7 @@ const stringToPublicKey = (s) => {
161
161
  for (let i = 0; i < exports.publicKeyDataSize; ++i) {
162
162
  key.data[i] = whole[i];
163
163
  }
164
- const digest = new Uint8Array((0, ripemd160_1.ripemd160)(key.data));
164
+ const digest = new Uint8Array((0, legacy_js_1.ripemd160)(key.data));
165
165
  if (digest[0] !== whole[exports.publicKeyDataSize] ||
166
166
  digest[1] !== whole[34] ||
167
167
  digest[2] !== whole[35] ||
@@ -264,9 +264,9 @@ const privateKeyToLegacyString = (key) => {
264
264
  const whole = [];
265
265
  whole.push(128);
266
266
  key.data.forEach((byte) => whole.push(byte));
267
- const digest = new Uint8Array(sha256_1.sha256
267
+ const digest = new Uint8Array(sha2_js_1.sha256
268
268
  .create()
269
- .update(sha256_1.sha256
269
+ .update(sha2_js_1.sha256
270
270
  .create()
271
271
  .update(Buffer.from(whole))
272
272
  .digest())
@@ -2,13 +2,13 @@
2
2
  // forked from https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/util/src/account.ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.pubToAddress = void 0;
5
- const secp256k1_1 = require("@noble/curves/secp256k1");
5
+ const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
6
6
  const keccak_js_1 = require("ethereum-cryptography/keccak.js");
7
7
  const helper_1 = require("./helper");
8
8
  const pubToAddress = function (pubKey, sanitize = false) {
9
9
  (0, helper_1.assertIsBytes)(pubKey);
10
10
  if (sanitize && pubKey.length !== 64) {
11
- pubKey = secp256k1_1.secp256k1.ProjectivePoint.fromHex(pubKey)
11
+ pubKey = secp256k1_js_1.secp256k1.ProjectivePoint.fromHex(pubKey)
12
12
  .toRawBytes(false)
13
13
  .slice(1);
14
14
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ecrecover = exports.calculateSigRecovery = void 0;
5
5
  exports.ecsign = ecsign;
6
- const secp256k1_1 = require("@noble/curves/secp256k1");
6
+ const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
7
7
  const constants_1 = require("./constants");
8
8
  const bytes_1 = require("./bytes");
9
9
  const calculateSigRecovery = (v, chainId) => {
@@ -19,7 +19,7 @@ function isValidSigRecovery(recovery) {
19
19
  return recovery === constants_1.BIGINT_0 || recovery === constants_1.BIGINT_1;
20
20
  }
21
21
  function ecsign(msgHash, privateKey, chainId) {
22
- const sig = secp256k1_1.secp256k1.sign(msgHash, privateKey);
22
+ const sig = secp256k1_js_1.secp256k1.sign(msgHash, privateKey);
23
23
  const buf = sig.toCompactRawBytes();
24
24
  const r = buf.slice(0, 32);
25
25
  const s = buf.slice(32, 64);
@@ -37,7 +37,7 @@ const ecrecover = function (msgHash, v, r, s, chainId) {
37
37
  if (!isValidSigRecovery(recovery)) {
38
38
  throw new Error("Invalid signature v value");
39
39
  }
40
- const sig = secp256k1_1.secp256k1.Signature.fromCompact(signature).addRecoveryBit(Number(recovery));
40
+ const sig = secp256k1_js_1.secp256k1.Signature.fromCompact(signature).addRecoveryBit(Number(recovery));
41
41
  const senderPubKey = sig.recoverPublicKey(msgHash);
42
42
  return senderPubKey.toRawBytes(false).slice(1);
43
43
  };
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Factory = void 0;
7
- const sha256_1 = require("@noble/hashes/sha256");
7
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
8
8
  const base_x_1 = __importDefault(require("base-x"));
9
9
  const FAMILY_SEED = 0x21; // 33
10
10
  const ED25519_SEED = [0x01, 0xe1, 0x4b]; // [1, 225, 75]
@@ -113,7 +113,7 @@ class Codec {
113
113
  }
114
114
  const Factory = (alphabet) => {
115
115
  const codecWithAlphabet = new Codec({
116
- sha256: (bytes) => sha256_1.sha256
116
+ sha256: (bytes) => sha2_js_1.sha256
117
117
  .create()
118
118
  .update(bytes)
119
119
  .digest(),
@@ -150,7 +150,7 @@ const Factory = (alphabet) => {
150
150
  try {
151
151
  decodeAccountID(address);
152
152
  }
153
- catch (_) {
153
+ catch (_a) {
154
154
  return false;
155
155
  }
156
156
  return true;