I am providing the sample code which I am using for generating private key from seed/passphrase but it is generating different keys. I known about BIP-32/44/39.
I know that it is not a good practice, but these are desperate times and i don’t have much in that wallet.
Full details at : Trezor script to generate the private keys from seed. · GitHub
const hdkey = require('hdkey')
const bip39 = require('bip39')
const ethUtil = require('ethereumjs-util')
const BigNumber = require('bignumber.js');
require('dotenv').config()
function hdwallet(){
let mnemonic , seed;
if (! process.env.MNEMONIC) {
mnemonic = bip39.generateMnemonic(); //generates string
} else {
mnemonic = process.env.MNEMONIC;
}
seed = bip39.mnemonicToSeedSync(mnemonic, process.env.PASSWORD).toString('hex');
const root = hdkey.fromMasterSeed(seed);
const addrNode = root.derive("m/44'/60'/0'/0/0"+ind); //line 1
const pubKey = ethUtil.privateToPublic(addrNode._privateKey);
const addr = ethUtil.publicToAddress(pubKey);
let address = ethUtil.toChecksumAddress('0x'+addr.toString('hex'));
console.log("priv key: ", addrNode._privateKey.toString('hex'))
// console.log("pub: ", '0x'+pubKey.toString('hex'))
address = address.toString('hex')
console.log("address : ", address)
return address
}
hdwallet()