HD Wallets
Overview
Purpose
Basic Usage
Initialize Key Deriver
import { KeyDeriver, PrivateKey } from '@bsv/sdk';
// Initialize with a master private key
const rootKey = PrivateKey.fromRandom();
const keyDeriver = new KeyDeriver(rootKey);
// Or use an existing master key
const masterKey = PrivateKey.fromWif('L5EY1SbTvvPNSdCYQe1EJHfXCBBT4PmnF6CDbzCm9iifZptUvDGB');
const deriver = new KeyDeriver(masterKey);Derive Public Keys
Derive Private Keys
Derive Symmetric Keys
Key Features
1. BRC-42 Compliant Key Derivation
2. Counterparty-Specific Derivation
3. Protocol Isolation
4. Master Key Recovery
API Reference
KeyDeriver Class
Constructor
derivePublicKey()
derivePrivateKey()
deriveSymmetricKey()
revealCounterpartySecret()
revealSpecificSecret()
Common Patterns
Pattern 1: Payment Address Generation
Pattern 2: Secure Messaging with Symmetric Keys
Pattern 3: Multi-Protocol Wallet with Change Addresses
Security Considerations
Master Key Protection
Security Level Selection
Counterparty Validation
Key ID Uniqueness
Performance Considerations
Key Derivation Caching
Batch Key Derivation
Related Components
Best Practices
1. Master Key Management
2. Protocol Versioning
3. Key ID Documentation
4. Counterparty Context
5. Backup and Recovery
Troubleshooting
Issue: Derived Keys Don't Match After Recovery
Issue: Performance Degradation with Many Derivations
Issue: Incorrect Counterparty Key Type
Issue: Protocol Name Collision
Further Reading
BRC Standards
Related Documentation
Tutorials and Examples
Status
Last updated
