@thru/crypto gives you the two building blocks for wallet onboarding flows: generate or validate a mnemonic, then derive Thru accounts from the resulting 64-byte seed.
Install
Import
Exports
| Export | What it does |
|---|---|
MnemonicGenerator | Generate a 12-word mnemonic, validate a phrase, and convert it to a 64-byte seed. |
ThruHDWallet | Derive Thru account keys and addresses from a seed using SLIP-0010 Ed25519 derivation. |
getWebCrypto | Re-exported helper for resolving Web Crypto support through @thru/helpers. |
When to use it
Use@thru/crypto when you need wallet onboarding primitives: mnemonics, seeds, and deterministic account derivation.
Use @thru/helpers when you only need address or signature encoding, byte conversion, or Web Crypto access.
Quick decision
| Need | Use |
|---|---|
| Create or validate a seed phrase | MnemonicGenerator |
| Derive one or more Thru accounts from a seed | ThruHDWallet |
| Check browser Web Crypto support | getWebCrypto |
Mnemonic generation
MnemonicGenerator works with the English BIP39 wordlist.
generate()returns a new 12-word mnemonic.validate(phrase)checks whether a phrase is valid.toSeed(phrase, passphrase?)converts a valid phrase into a 64-byte seed.getWordCount(phrase)returns the number of words in a phrase.
Account derivation
ThruHDWallet derives accounts from a 64-byte seed using the Thru coin type 9999.
THRU_COIN_TYPEis9999.THRU_DERIVATION_PATHism/44'/9999'.getAccount(seed, accountIndex?, change?)returns the derived address, public key, private key, secret key, and path.deriveAccounts(seed, count)returns a list of derived accounts starting at index0.isValidPath(path)checks whether a derivation path is syntactically valid.
getAccount() requires a 64-byte seed and a non-negative account index.
The derived path format is m/44'/9999'/{accountIndex}'/{change}'.