I am trying to get proper public address for Solana wallet using solana-web3.js at my react-native test project
import { Keypair} from '@solana/web3.js';
import * as bip39 from 'bip39';
import * as bip32 from 'bip32';
const derivePath = "m/44'/501'/0'/0'";
const mnemonic = "...12 word phrase"
const seed: Buffer = yield bip39.mnemonicToSeed(mnemonic);
// also tried to slice seed.slice(0, 32);
const derivedSeed = bip32.fromSeed(seed).derivePath(derivePath).privateKey;
const keypair = Keypair.fromSeed(derivedSeed);
const publicKey = keypair.publicKey.toString();
I took derive path that is supposed to be for Phantom wallet (and could be chosen at Solflare wallet) But the problem is - I do not get the same public key as I get at these browser wallets.
So where am I possibly making mistake at code above?
UPDATE: When I use 'ed25519-hd-key' lib instead of 'bip32' to get derived seed problem disappears.
import * as ed25519 from 'ed25519-hd-key';
const derivedSeed = ed25519.derivePath(derivePath, seed.toString('hex')).key;