Overview
src/utils/mnemonic.rs is called from wallet.rs for --mnemonic wallet creation. The SEP-0005 derivation path m/44'/148'/index' must use HMAC-SHA512 on the BIP39 seed for hierarchical key derivation. Stellar's SEP-0005 uses a specific derivation that differs from Bitcoin's BIP32 in that it uses ed25519 keys with hardened-only paths. Without validation against official test vectors, silently wrong key derivation could cause users to generate keys they cannot recover.
Resolution
Implement SEP-0005 compliant derivation in mnemonic.rs: generate BIP39 seed from mnemonic + passphrase using bip39::Mnemonic::to_seed(passphrase). Then for each path component in m/44'/148'/account_index': derive the master key using HMAC-SHA512(key="ed25519 seed", data=seed_bytes) — the left 32 bytes are the private key, right 32 bytes the chain code. For child keys, compute HMAC-SHA512(key=chain_code, data=0x00 || private_key || ser32(index | 0x80000000)). Validate the output against known test vectors from the SEP-0005 spec. Add a starforge wallet derive --mnemonic --account-index 0..9 command that shows all 10 derived addresses, allowing users to identify which index their existing wallet used. Write unit tests with the official SEP-0005 test vectors.
Overview
src/utils/mnemonic.rsis called fromwallet.rsfor--mnemonicwallet creation. The SEP-0005 derivation pathm/44'/148'/index'must use HMAC-SHA512 on the BIP39 seed for hierarchical key derivation. Stellar's SEP-0005 uses a specific derivation that differs from Bitcoin's BIP32 in that it usesed25519keys with hardened-only paths. Without validation against official test vectors, silently wrong key derivation could cause users to generate keys they cannot recover.Resolution
Implement SEP-0005 compliant derivation in
mnemonic.rs: generate BIP39 seed from mnemonic + passphrase usingbip39::Mnemonic::to_seed(passphrase). Then for each path component inm/44'/148'/account_index': derive the master key usingHMAC-SHA512(key="ed25519 seed", data=seed_bytes)— the left 32 bytes are the private key, right 32 bytes the chain code. For child keys, computeHMAC-SHA512(key=chain_code, data=0x00 || private_key || ser32(index | 0x80000000)). Validate the output against known test vectors from the SEP-0005 spec. Add astarforge wallet derive --mnemonic --account-index 0..9command that shows all 10 derived addresses, allowing users to identify which index their existing wallet used. Write unit tests with the official SEP-0005 test vectors.