@lucid-evolution/wallet 0.4.0 → 0.4.1

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/dist/index.cjs CHANGED
@@ -48,6 +48,26 @@ var CML = __toESM(require("@lucid-evolution/cml"), 1);
48
48
 
49
49
  // src/wallet.ts
50
50
  var import_bip39 = require("bip39");
51
+
52
+ // src/root_key.ts
53
+ var nodePbkdf2Sync = (() => {
54
+ try {
55
+ return globalThis.process?.getBuiltinModule?.("node:crypto")?.pbkdf2Sync;
56
+ } catch {
57
+ return void 0;
58
+ }
59
+ })();
60
+ var bip32RootKeyFromEntropy = (entropy, password) => {
61
+ if (!nodePbkdf2Sync)
62
+ return CML.Bip32PrivateKey.from_bip39_entropy(entropy, password);
63
+ const key = nodePbkdf2Sync(password, entropy, 4096, 96, "sha512");
64
+ key[0] &= 248;
65
+ key[31] &= 31;
66
+ key[31] |= 64;
67
+ return CML.Bip32PrivateKey.from_raw_bytes(key);
68
+ };
69
+
70
+ // src/wallet.ts
51
71
  function walletFromSeed(seed, options = {}) {
52
72
  const {
53
73
  addressType = "Base",
@@ -59,7 +79,7 @@ function walletFromSeed(seed, options = {}) {
59
79
  return 2147483648 + num;
60
80
  }
61
81
  const entropy = (0, import_bip39.mnemonicToEntropy)(seed);
62
- const rootKey = CML.Bip32PrivateKey.from_bip39_entropy(
82
+ const rootKey = bip32RootKeyFromEntropy(
63
83
  (0, import_core_utils.fromHex)(entropy),
64
84
  options?.password ? new TextEncoder().encode(options.password) : new Uint8Array()
65
85
  );
package/dist/index.js CHANGED
@@ -7,6 +7,26 @@ import * as CML from "@lucid-evolution/cml";
7
7
 
8
8
  // src/wallet.ts
9
9
  import { mnemonicToEntropy } from "bip39";
10
+
11
+ // src/root_key.ts
12
+ var nodePbkdf2Sync = (() => {
13
+ try {
14
+ return globalThis.process?.getBuiltinModule?.("node:crypto")?.pbkdf2Sync;
15
+ } catch {
16
+ return void 0;
17
+ }
18
+ })();
19
+ var bip32RootKeyFromEntropy = (entropy, password) => {
20
+ if (!nodePbkdf2Sync)
21
+ return CML.Bip32PrivateKey.from_bip39_entropy(entropy, password);
22
+ const key = nodePbkdf2Sync(password, entropy, 4096, 96, "sha512");
23
+ key[0] &= 248;
24
+ key[31] &= 31;
25
+ key[31] |= 64;
26
+ return CML.Bip32PrivateKey.from_raw_bytes(key);
27
+ };
28
+
29
+ // src/wallet.ts
10
30
  function walletFromSeed(seed, options = {}) {
11
31
  const {
12
32
  addressType = "Base",
@@ -18,7 +38,7 @@ function walletFromSeed(seed, options = {}) {
18
38
  return 2147483648 + num;
19
39
  }
20
40
  const entropy = mnemonicToEntropy(seed);
21
- const rootKey = CML.Bip32PrivateKey.from_bip39_entropy(
41
+ const rootKey = bip32RootKeyFromEntropy(
22
42
  fromHex(entropy),
23
43
  options?.password ? new TextEncoder().encode(options.password) : new Uint8Array()
24
44
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/wallet",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,14 +23,15 @@
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
25
  "bip39": "^3.1.0",
26
- "@lucid-evolution/cml": "0.1.0",
27
- "@lucid-evolution/core-types": "0.5.0",
28
- "@lucid-evolution/core-utils": "0.2.0",
29
- "@lucid-evolution/sign_data": "0.2.0",
30
- "@lucid-evolution/utils": "0.2.0"
26
+ "@lucid-evolution/core-types": "0.5.1",
27
+ "@lucid-evolution/core-utils": "0.2.1",
28
+ "@lucid-evolution/cml": "0.1.1",
29
+ "@lucid-evolution/sign_data": "0.2.1",
30
+ "@lucid-evolution/utils": "0.2.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^20.12.8",
34
+ "effect": "^3.12.7",
34
35
  "tsup": "^8.0.2",
35
36
  "typescript": "^5.4.5",
36
37
  "vitest": "^2.1.8"