mnemonicToSeed

fun mnemonicToSeed(mnemonic: String, passphrase: String = ""): ByteArray

Derives a seed from a mnemonic phrase and optional passphrase.

⚠️ CRITICAL: LACE WALLET COMPATIBILITY ⚠️

This implementation returns ONLY the first 32 bytes of the BIP-39 seed to maintain compatibility with Lace wallet (the most popular Midnight wallet).

Standard BIP-39 behavior produces 64 bytes, but Lace uses only 32 bytes.

Why This Non-Standard Behavior?

Lace wallet uses a truncated seed due to a "documentation gap" (confirmed by Lace team in GitHub issue #2133). This creates an ecosystem split:

  • Lace Standard: First 32 bytes only

  • Official Midnight SDK: Full 64 bytes

We follow Lace to ensure wallet interoperability - users can import/export wallets between Kuira and Lace seamlessly.

Security Impact

None - 32 bytes (256 bits) provides the same security as Bitcoin/Ethereum. The entropy reduction (512→256 bits) is negligible in practice.

Migration

  • ✅ Lace → Kuira: Import works perfectly

  • ✅ Kuira → Lace: Import works perfectly

  • ⚠️ Official SDK → Kuira: Different addresses (incompatible)

References

  • Full Explanation: See docs/LACE_COMPATIBILITY.md

  • Lace GitHub Issue: https://github.com/input-output-hk/lace/issues/2133

  • BIP-39 Spec: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

Return

64-byte seed (full BIP-39 PBKDF2 output, matching Lace wallet)

Parameters

mnemonic

The mnemonic phrase (12-24 words)

passphrase

Optional passphrase for additional security (default: empty string)

Throws

if mnemonic is invalid