hd-wallet-ui 1.1.5 → 1.2.0
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/package.json +2 -2
- package/src/app.js +8 -13
- package/src/constants.js +2 -23
- package/src/lib.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hd-wallet-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "HD Wallet modal UI — login, keys, identity, trust map, and security bond. Attach to any button in your app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/app.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"bip39": "^3.1.0",
|
|
35
35
|
"buffer": "^6.0.3",
|
|
36
36
|
"flatbuffers": "^25.9.23",
|
|
37
|
-
"hd-wallet-wasm": "^1.
|
|
37
|
+
"hd-wallet-wasm": "^1.2.0",
|
|
38
38
|
"qrcode": "^1.5.3",
|
|
39
39
|
"vcard-cryptoperson": "^1.1.10"
|
|
40
40
|
},
|
package/src/app.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// External Imports
|
|
10
10
|
// =============================================================================
|
|
11
11
|
|
|
12
|
-
import initHDWallet, { Curve } from 'hd-wallet-wasm';
|
|
12
|
+
import initHDWallet, { Curve, getSigningKey, getEncryptionKey, buildSigningPath, buildEncryptionPath, WellKnownCoinType } from 'hd-wallet-wasm';
|
|
13
13
|
import { x25519, ed25519 } from '@noble/curves/ed25519';
|
|
14
14
|
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
15
15
|
import { p256 } from '@noble/curves/p256';
|
|
@@ -36,8 +36,6 @@ import WalletStorage, { StorageMethod } from './wallet-storage.js';
|
|
|
36
36
|
import {
|
|
37
37
|
cryptoConfig,
|
|
38
38
|
coinTypeToConfig,
|
|
39
|
-
buildSigningPath,
|
|
40
|
-
buildEncryptionPath,
|
|
41
39
|
PKI_STORAGE_KEY,
|
|
42
40
|
} from './constants.js';
|
|
43
41
|
|
|
@@ -366,19 +364,16 @@ async function deriveKeysFromSeed(seedPhrase) {
|
|
|
366
364
|
* This ensures addresses match what the HD derivation grid produces.
|
|
367
365
|
*/
|
|
368
366
|
function deriveKeysFromHDRoot(hdRoot) {
|
|
369
|
-
// BTC signing
|
|
370
|
-
const
|
|
371
|
-
const secp256k1PrivKey = btcKey.privateKey();
|
|
372
|
-
const secp256k1PubKey = btcKey.publicKey();
|
|
367
|
+
// BTC signing key m/44'/0'/0'/0/0 — secp256k1
|
|
368
|
+
const btcSigning = getSigningKey(hdRoot, 0, 0, 0);
|
|
373
369
|
|
|
374
|
-
// SOL signing
|
|
375
|
-
const
|
|
376
|
-
const
|
|
377
|
-
const ed25519PubKey = ed25519.getPublicKey(ed25519PrivKey);
|
|
370
|
+
// SOL signing key m/44'/501'/0'/0/0 — ed25519
|
|
371
|
+
const solSigning = getSigningKey(hdRoot, 501, 0, 0);
|
|
372
|
+
const ed25519PubKey = ed25519.getPublicKey(solSigning.privateKey);
|
|
378
373
|
|
|
379
374
|
return {
|
|
380
|
-
secp256k1: { privateKey:
|
|
381
|
-
ed25519: { privateKey:
|
|
375
|
+
secp256k1: { privateKey: btcSigning.privateKey, publicKey: btcSigning.publicKey },
|
|
376
|
+
ed25519: { privateKey: solSigning.privateKey, publicKey: ed25519PubKey },
|
|
382
377
|
};
|
|
383
378
|
}
|
|
384
379
|
|
package/src/constants.js
CHANGED
|
@@ -51,31 +51,10 @@ export const coinTypeToConfig = Object.fromEntries(
|
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// =============================================================================
|
|
54
|
-
// Derivation Path Helpers
|
|
54
|
+
// Derivation Path Helpers (re-exported from hd-wallet-wasm)
|
|
55
55
|
// =============================================================================
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
* Build a BIP44 signing path: m/44'/coinType'/account'/0/index
|
|
59
|
-
* @param {string|number} coinType - Coin type number
|
|
60
|
-
* @param {string|number} account - Account index
|
|
61
|
-
* @param {string|number} index - Address index
|
|
62
|
-
* @returns {string} BIP44 derivation path
|
|
63
|
-
*/
|
|
64
|
-
export function buildSigningPath(coinType, account = '0', index = '0') {
|
|
65
|
-
return `m/44'/${coinType}'/${account}'/0/${index}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Build an encryption key path: m/44'/coinType'/account'/1/index
|
|
70
|
-
* Uses change=1 to separate encryption keys from signing keys
|
|
71
|
-
* @param {string|number} coinType - Coin type number
|
|
72
|
-
* @param {string|number} account - Account index
|
|
73
|
-
* @param {string|number} index - Address index
|
|
74
|
-
* @returns {string} Derivation path for encryption keys
|
|
75
|
-
*/
|
|
76
|
-
export function buildEncryptionPath(coinType, account = '0', index = '0') {
|
|
77
|
-
return `m/44'/${coinType}'/${account}'/1/${index}`;
|
|
78
|
-
}
|
|
57
|
+
export { buildSigningPath, buildEncryptionPath, getSigningKey, getEncryptionKey, WellKnownCoinType } from 'hd-wallet-wasm';
|
|
79
58
|
|
|
80
59
|
// =============================================================================
|
|
81
60
|
// PKI Storage Key
|