fix: SLIP-10 Ed25519 Solana derivation + auto-sweep migration#69
Merged
Conversation
…ible) The old derivation used secp256k1 BIP-32 (HDKey) for Solana keys at m/44'/501'/0'/0'. All Solana wallets (Phantom, Solflare, Backpack) use SLIP-10 Ed25519 instead. Same mnemonic + same path + different curve = completely different address, making mnemonic recovery impossible. Changes: - wallet.ts: SLIP-10 Ed25519 derivation via @noble/hashes HMAC-SHA512 - wallet.ts: old function preserved as deriveSolanaKeyBytesLegacy() for sweep - auth.ts: migration detection on startup, logs old/new addresses - solana-sweep.ts: new file to transfer USDC from legacy to new wallet - index.ts: /wallet migrate-solana command + exports - wallet.test.ts: known test vectors, Phantom address verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/wallet migrate-solanacommand to sweep USDC from legacy wallet to new walletProblem
deriveSolanaKeyBytes()used@scure/bip32'sHDKey(secp256k1) for pathm/44'/501'/0'/0'. All Solana wallets use SLIP-10 Ed25519. Same mnemonic + same path + different elliptic curve = completely different address. Users could not recover their Solana wallet from the 24-word mnemonic in any standard wallet.Changes
src/wallet.tsderiveSolanaKeyBytesLegacy()src/auth.tssrc/solana-sweep.tssrc/index.ts/wallet migrate-solanacommand + exportssrc/cli.tssrc/wallet.test.tsTest plan
npm test— 297 passed, 0 failed"abandon...art"→ SLIP-10 address3Cy3YNTFywCmxoxt8n7UH6hg6dLo5uACowX3CFceaSnxFML75Ca...)tsc --noEmit)/wallet migrate-solanawith funded legacy wallet