getSecretKey method

Future<List<int>> getSecretKey(
  1. Map user,
  2. String password
)

Implementation

Future<List<int>> getSecretKey(Map user, String password) async {
  if (this.secretKey != null) {
    return this.secretKey!;
  }

  if (this.encSecretKey.isEmpty) {
    throw Exception("Empty encrypted vault secret key.");
  }

  String pkPem = await Robomotion().getPrivateKey(
    user,
    password,
  );

  final sk = await rsa.RSA.decryptOAEPBytes(
    base64Decode(this.encSecretKey),
    "",
    rsa.Hash.SHA256,
    pkPem,
  );

  this.secretKey = sk.toList();
  return this.secretKey!;
}