This repository provides the core BIP39 workflows for the English wordlist profile:
- Convert entropy to a mnemonic sentence
- Convert a mnemonic sentence back to entropy
- Derive a 64-byte seed from a mnemonic and passphrase
- Validate mnemonic structure, word membership, and checksum
- Use the same behavior from both a TypeScript API and a CLI
It is backed by pinned specification assets in assets/, including the English wordlist and official test vectors.
- This project targets the English BIP39 profile only.
- The CLI and exported APIs distinguish between strict parsing and compatibility normalization; do not assume all inputs are auto-corrected.
- Generated mnemonics and derived seeds are sensitive secrets. Never commit them, log them, or share them in screenshots.
- This repository implements BIP39 behavior only. It does not implement BIP32, derivation paths, addresses, or wallet UX.
pnpm installpnpm buildnode dist/cli/index.js --helpGenerate a 12-word mnemonic:
node dist/cli/index.js generate-mnemonic --words 12Convert entropy hex to a mnemonic:
node dist/cli/index.js entropy-to-mnemonic 00000000000000000000000000000000Validate a mnemonic:
node dist/cli/index.js validate "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"Derive a seed:
node dist/cli/index.js mnemonic-to-seed "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" --passphrase TREZORimport {
entropyToMnemonic,
generateEntropy,
mnemonicToEntropy,
mnemonicToSeed,
validateMnemonic,
} from "./dist/index.js";
const entropy = generateEntropy(16);
const mnemonic = entropyToMnemonic(entropy);
const roundTripEntropy = mnemonicToEntropy(mnemonic);
const seed = mnemonicToSeed(mnemonic, "TREZOR");
const validation = validateMnemonic(mnemonic);
console.log({
mnemonic,
roundTripEntropyLength: roundTripEntropy.length,
seedLength: seed.length,
validation,
});- Ensure
Node.js >= 24is installed. - Ensure
pnpm 10.30.0or a compatiblepnpmversion is available. - Clone the repository.
- Install dependencies with
pnpm install. - Run
pnpm testto execute the Vitest suite once. - Run
pnpm test:watchfor watch mode during development. - Run
pnpm typecheckto verify TypeScript types. - Run
pnpm lintto check formatting and static issues. - Run
pnpm buildto emit JavaScript intodist/.
- The project uses
Vitestwith a Node test environment. - Tests live in
test/and cover both unit behavior and CLI integration flows. - Use
pnpm testfor a single run andpnpm test:watchwhile iterating. - Use
pnpm run cito run lint, typecheck, tests, and build together.
- Compiled JavaScript is emitted to
dist/. - The CLI entry point is emitted to
dist/cli/index.js. - Source files remain in
src/. - Vitest test files remain in
test/and are not emitted by the build.
No runtime configuration file is required.
The main repository-level configuration files are:
package.jsonfor scripts and package metadatatsconfig.jsonfor TypeScript compilation and build output settingsbiome.jsonfor linting and formatting
.
├── assets/ # Pinned specification assets and test vectors
├── src/ # TypeScript source code
│ ├── bip39/ # Core entropy/mnemonic/seed workflows
│ ├── bits/ # Bit conversion helpers
│ ├── cli/ # Command-line interface
│ ├── constants/ # Fixed BIP39 constants and mappings
│ ├── crypto/ # SHA-256 and PBKDF2 wrappers
│ ├── entropy/ # Secure entropy generation
│ ├── errors/ # Standard error codes
│ ├── integration/ # Error messaging and integration adapters
│ ├── normalize/ # Compatibility input normalization
│ ├── parser/ # Strict mnemonic parsing rules
│ ├── types/ # Shared DTOs and result types
│ └── index.ts # Public export surface
├── test/ # Unit and integration tests
├── biome.json # Lint/format configuration
├── package.json # Scripts and package metadata
├── README.md # Project overview and usage
└── tsconfig.json # TypeScript compilation configuration
MIT - see LICENSE.