getDecryptedSeed method

Future<Map<String, dynamic>?> getDecryptedSeed(
  1. String? pubKey,
  2. dynamic password
)

Implementation

Future<Map<String, dynamic>?> getDecryptedSeed(
    String? pubKey, password) async {
  final key = Encrypt.passwordToEncryptKey(password);
  final mnemonic = _storage.encryptedMnemonics.val[pubKey];
  if (mnemonic != null) {
    final res = {'type': KeyType.mnemonic.toString().split('.')[1]};
    try {
      res['seed'] =
          (await FlutterAesEcbPkcs5.decryptString(mnemonic, key)) ?? "";
    } catch (err) {
      print(err);
    }
    return res;
  }
  final rawSeed = _storage.encryptedRawSeeds.val[pubKey];
  if (rawSeed != null) {
    final res = {'type': KeyType.rawSeed.toString().split('.')[1]};
    try {
      res['seed'] =
          (await FlutterAesEcbPkcs5.decryptString(rawSeed, key)) ?? "";
    } catch (err) {
      print(err);
    }
    return res;
  }
  return null;
}