hd-wallet-wasm 1.1.3 → 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/README.md +88 -4
- package/dist/hd-wallet.js +1 -1
- package/dist/hd-wallet.wasm +0 -0
- package/dist/index.d.ts +37 -0
- package/package.json +1 -1
- package/src/index.d.ts +37 -0
- package/src/index.mjs +192 -0
package/README.md
CHANGED
|
@@ -112,6 +112,50 @@ const xpub = master.toXpub();
|
|
|
112
112
|
const pubOnly = master.neutered();
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
### Signing & Encryption Keys (BIP-44)
|
|
116
|
+
|
|
117
|
+
The library provides dedicated helpers for deriving separate signing and encryption
|
|
118
|
+
keypairs from a single HD root. Signing keys use BIP-44 change=0 (external chain);
|
|
119
|
+
encryption keys use change=1 (internal chain).
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
import { getSigningKey, getEncryptionKey, buildSigningPath, buildEncryptionPath, WellKnownCoinType } from 'hd-wallet-wasm';
|
|
123
|
+
|
|
124
|
+
const master = wallet.hdkey.fromSeed(seed);
|
|
125
|
+
|
|
126
|
+
// Get signing keypair for Ethereum (m/44'/60'/0'/0/0)
|
|
127
|
+
const signing = getSigningKey(master, 60);
|
|
128
|
+
console.log('Signing pubkey:', wallet.utils.encodeHex(signing.publicKey));
|
|
129
|
+
console.log('Path:', signing.path); // "m/44'/60'/0'/0/0"
|
|
130
|
+
|
|
131
|
+
// Get encryption keypair for OrbPro marketplace (m/44'/9999'/0'/1/0)
|
|
132
|
+
const encryption = getEncryptionKey(master, WellKnownCoinType.ORBPRO_MARKETPLACE);
|
|
133
|
+
console.log('Encryption pubkey:', wallet.utils.encodeHex(encryption.publicKey));
|
|
134
|
+
|
|
135
|
+
// Use encryption key for ECDH key agreement
|
|
136
|
+
const shared = wallet.curves.secp256k1.ecdh(encryption.privateKey, otherPublicKey);
|
|
137
|
+
|
|
138
|
+
// Multiple keys per account (e.g., one per plugin)
|
|
139
|
+
const plugin0Key = getEncryptionKey(master, 9999, '0', '0');
|
|
140
|
+
const plugin1Key = getEncryptionKey(master, 9999, '0', '1');
|
|
141
|
+
|
|
142
|
+
// Path helpers are also available directly
|
|
143
|
+
const sigPath = buildSigningPath(60); // "m/44'/60'/0'/0/0"
|
|
144
|
+
const encPath = buildEncryptionPath(9999); // "m/44'/9999'/0'/1/0"
|
|
145
|
+
|
|
146
|
+
// Clean up
|
|
147
|
+
wallet.utils.secureWipe(signing.privateKey);
|
|
148
|
+
wallet.utils.secureWipe(encryption.privateKey);
|
|
149
|
+
master.wipe();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Also available as instance methods on the wallet module:
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
const signing = wallet.getSigningKey(master, 60);
|
|
156
|
+
const encryption = wallet.getEncryptionKey(master, 9999);
|
|
157
|
+
```
|
|
158
|
+
|
|
115
159
|
### Multi-Curve Cryptography
|
|
116
160
|
|
|
117
161
|
```javascript
|
|
@@ -293,11 +337,51 @@ const wallet = await init();
|
|
|
293
337
|
- Consider using hardware wallets for high-value operations
|
|
294
338
|
- The library enforces key separation: external chain (0) for signing, internal chain (1) for encryption
|
|
295
339
|
|
|
296
|
-
## FIPS Mode
|
|
340
|
+
## FIPS 140-3 Mode
|
|
341
|
+
|
|
342
|
+
The published NPM package includes OpenSSL 3.0.9 FIPS Provider support for compliance-critical applications.
|
|
343
|
+
|
|
344
|
+
### Enabling FIPS Mode
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
import init from 'hd-wallet-wasm';
|
|
348
|
+
|
|
349
|
+
const wallet = await init();
|
|
350
|
+
|
|
351
|
+
// Check if OpenSSL is available
|
|
352
|
+
console.log('OpenSSL compiled:', wallet.isOpenSSL());
|
|
353
|
+
|
|
354
|
+
// Initialize FIPS mode
|
|
355
|
+
const fipsEnabled = wallet.initFips();
|
|
356
|
+
console.log('FIPS active:', wallet.isOpenSSLFips());
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Algorithm Routing
|
|
360
|
+
|
|
361
|
+
When FIPS mode is active, approved algorithms use OpenSSL FIPS provider:
|
|
362
|
+
|
|
363
|
+
| Algorithm | FIPS Mode | Default |
|
|
364
|
+
|-----------|-----------|---------|
|
|
365
|
+
| SHA-256/384/512 | OpenSSL FIPS | Crypto++ |
|
|
366
|
+
| AES-256-GCM | OpenSSL FIPS | Crypto++ |
|
|
367
|
+
| ECDSA P-256/P-384 | OpenSSL FIPS | Crypto++ |
|
|
368
|
+
| HKDF/PBKDF2 | OpenSSL FIPS | Crypto++ |
|
|
369
|
+
| secp256k1 | Crypto++ | Crypto++ |
|
|
370
|
+
| Ed25519 | Crypto++ | Crypto++ |
|
|
371
|
+
| Keccak-256 | Crypto++ | Crypto++ |
|
|
372
|
+
|
|
373
|
+
**Note:** secp256k1 (Bitcoin/Ethereum) and Ed25519 (Solana) are not FIPS-approved and always use Crypto++.
|
|
374
|
+
|
|
375
|
+
### API Reference
|
|
376
|
+
|
|
377
|
+
| Method | Description |
|
|
378
|
+
|--------|-------------|
|
|
379
|
+
| `wallet.isOpenSSL()` | Check if OpenSSL backend is compiled in |
|
|
380
|
+
| `wallet.initFips()` | Initialize FIPS mode; returns true if successful |
|
|
381
|
+
| `wallet.isOpenSSLFips()` | Check if FIPS provider is currently active |
|
|
382
|
+
| `wallet.isFipsMode()` | Check if compiled with FIPS mode enabled |
|
|
297
383
|
|
|
298
|
-
|
|
299
|
-
- P-256 and P-384 ECDSA (not secp256k1 or Ed25519)
|
|
300
|
-
- FIPS-approved random number generation
|
|
384
|
+
See the [main README](https://github.com/DigitalArsenal/hd-wallet-wasm#fips-140-3-compliance) for comprehensive FIPS documentation.
|
|
301
385
|
|
|
302
386
|
## License
|
|
303
387
|
|