decryptPKid function

Future<String> decryptPKid(
  1. String cipherText,
  2. Uint8List bobPublicKey,
  3. Uint8List bobSecretKey
)

Implementation

Future<String> decryptPKid(String cipherText, Uint8List bobPublicKey, Uint8List bobSecretKey) async {
  Uint8List cipherEncodedText = base64.decode(cipherText);

  Uint8List publicKey =  Sodium.cryptoSignEd25519PkToCurve25519(bobPublicKey);
  Uint8List secretKey =  Sodium.cryptoSignEd25519SkToCurve25519(bobSecretKey);

  Uint8List decrypted =  Sodium.cryptoBoxSealOpen(cipherEncodedText, publicKey, secretKey);

  String base64DecryptedMessage = new String.fromCharCodes(decrypted);
  return base64DecryptedMessage;
}