HD Wallet WASM

A comprehensive hierarchical deterministic wallet implementation in pure C++, compiled to WebAssembly for cross-platform compatibility. BIP-32/39/44 compliant with multi-curve cryptography and multi-chain support.

GitHub
bash
npm install hd-wallet-wasm

Features

BIP Standards Compliant

Full implementation of BIP-32 (HD keys), BIP-39 (mnemonic phrases), BIP-44/49/84 (account hierarchy), and SLIP-44 (coin types).

Multi-Curve Cryptography

Support for secp256k1 (Bitcoin, Ethereum), Ed25519 (Solana, Polkadot), NIST P-256, P-384, and X25519 key exchange.

Multi-Chain Support

Bitcoin (all address types), Ethereum/EVM, Solana, Cosmos/Tendermint, Polkadot/Substrate, and 50+ coins via SLIP-44.

WebAssembly Native

Compiled to WASM for browser, Node.js, and WASI runtimes. Works with Go, Rust, Python, and any WASI-compatible host.

Hardware Wallet Support

Abstraction layer for Trezor, Ledger, and KeepKey devices with WASI bridge integration for USB/HID communication.

Security First

Secure memory wiping, optional FIPS-compliant mode, and comprehensive input validation for production use.

Quick Start

javascript
import HDWalletWasm from 'hd-wallet-wasm';

const wallet = await HDWalletWasm();
const mnemonic = wallet.mnemonic.generate(24);
const seed = wallet.mnemonic.toSeed(mnemonic, 'optional passphrase');
const masterKey = wallet.hdkey.fromSeed(seed);

const btcKey = masterKey.derivePath("m/84'/0'/0'/0/0");
const btcAddress = wallet.bitcoin.getAddress(btcKey.publicKey(), 2);

const ethKey = masterKey.derivePath("m/44'/60'/0'/0/0");
const ethAddress = wallet.ethereum.getAddress(ethKey.publicKey());

console.log('Bitcoin:', btcAddress);
console.log('Ethereum:', ethAddress);import HDWalletWasm from 'hd-wallet-wasm';

const wallet = await HDWalletWasm();
const seed = wallet.mnemonic.toSeed(mnemonic, 'passphrase');
const masterKey = wallet.hdkey.fromSeed(seed);

// Sign a Bitcoin message (secp256k1)
const btcKey = masterKey.derivePath("m/84'/0'/0'/0/0");
const btcSig = wallet.bitcoin.signMessage('Hello Bitcoin!', btcKey.privateKey());

// Sign an Ethereum message (EIP-191)
const ethKey = masterKey.derivePath("m/44'/60'/0'/0/0");
const ethSig = wallet.ethereum.signMessage('Hello Ethereum!', ethKey.privateKey());

// Raw secp256k1 recoverable signature
const msgHash = wallet.utils.sha256('my message');
const { signature, recoveryId } = wallet.curves.secp256k1.signRecoverable(
  msgHash, btcKey.privateKey()
);

// Ed25519 signing (Solana)
const solKey = masterKey.derivePath("m/44'/501'/0'/0/0");
const edSig = wallet.curves.ed25519.sign('payload', solKey.privateKey());
const valid = wallet.curves.ed25519.verify('payload', edSig, solKey.publicKey());import HDWalletWasm from 'hd-wallet-wasm';

const wallet = await HDWalletWasm();

// Generate a 256-bit AES key and 12-byte IV
const aesKey = wallet.utils.generateAesKey(256);
const iv = wallet.utils.generateIv();

// Encrypt with AES-256-GCM
const plaintext = new TextEncoder().encode('Secret message');
const { ciphertext, tag } = wallet.utils.aesGcm.encrypt(aesKey, plaintext, iv);

// Decrypt
const decrypted = wallet.utils.aesGcm.decrypt(aesKey, ciphertext, tag, iv);
console.log(new TextDecoder().decode(decrypted)); // 'Secret message'

// With additional authenticated data (AAD)
const aad = new TextEncoder().encode('metadata');
const encrypted = wallet.utils.aesGcm.encrypt(aesKey, plaintext, iv, aad);
const result = wallet.utils.aesGcm.decrypt(
  aesKey, encrypted.ciphertext, encrypted.tag, iv, aad
);

Supported Blockchains

BitcoinP2PKH, P2SH, P2WPKH, Taproot
EthereumEIP-55, EIP-712, EIP-1559
SolanaEd25519 signatures
CosmosAmino & Direct signing
PolkadotSS58 addresses
LitecoinAll address types
DogecoinP2PKH addresses
+ 50 morevia SLIP-44

Adversarial Security

Rational actors drain compromised keys. Undrained value proves key integrity.

What is Adversarial Security?

Cryptographic public keys can derive addresses on cryptocurrency networks. By depositing value at those derived addresses, you create a game-theoretic security bond. A rational actor who compromises the private key will drain the funds — the payout is immediate, anonymous, and risk-free. This makes the balance a real-time indicator of key integrity: undrained value implies an uncompromised key.

Public Key
Derive Address
Deposit Value
Monitor
Trusted

Key Derivation

A public key used for signing data can mathematically derive addresses on multiple blockchain networks (BIP-32/44). One key pair serves both authentication and value custody.

Value as Trust Signal

Derived addresses are permissionless — anyone can deposit funds to signal trust in a key. The aggregate balance quantifies the economic cost of compromise.

Rational Actor Assumption

Draining funds is the dominant strategy: it's immediate, irreversible, and carries zero marginal risk. Undrained value therefore implies no compromise.

Real-Time Verification

Blockchain state is publicly auditable and updates every block. This provides continuous, permissionless proof of key integrity — not a certificate, but a live signal.

Read the Whitepaper
Loading WASM modules...