'How to generate new private keys from a mnemonic in Dart?

I am having trouble understanding how to generate new private keys (for example in case a new account is created) from the same mnemonic. The current function returns the same private key.

Future<String> getPrivateKey(String mnemonic) async {

  final seed = bip39.mnemonicToSeed(mnemonic);
  final master = await ED25519_HD_KEY.getMasterKeyFromSeed(seed);
  final privateKey = HEX.encode(master.key);
  return privateKey; 
}

Thhank you in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source