Flutter app crashes when generating bip39 keypair

92 Views Asked by At

I am generating keypair from memnomic phrase for my crypto app, and anytime i try to generate the address and private key, the whole app start to lag and crashes,i have also tried using the coompute isolate for this case, it is still the same,

// how it been called
var keys = await compute(calculateDashKey, mnemonic);

// implementation
Map calculateDashKey(String seedPhrase) {
  final seed = bip39.mnemonicToSeed(seedPhrase);
  final root = bip32.BIP32.fromSeed(seed);
  final node = root.derivePath("m/44'/5'/0'/0/0");
  var address = P2PKH(
          data: PaymentData(
            pubkey: node.publicKey,
          ),
          network: dash)
      .data
      .address;
  return {
    'address': address,
    'private_key': "0x${HEX.encode(node.privateKey)}"
  };
}
1

There are 1 best solutions below

1
murage kibicho On

I think the problem is with the library bip39. If you're using this bip39 library then you should look at the GitHub. It was last updated 2 years ago and it is a known issue that it freezes your UI. Perhaps you should find a new library or contact the original developer.