decryptMessage function
Future<String>
decryptMessage({
- required Secp256k1KeyIdentity identity,
- required Secp256k1PublicKey theirPublicKey,
- required String cipherText,
Implementation
Future<String> decryptMessage({
required Secp256k1KeyIdentity identity,
required Secp256k1PublicKey theirPublicKey,
required String cipherText,
}) async {
final arr = cipherText.split('?iv=');
final emsg = arr[0];
final iv = arr[1];
final sharedPoint = await getECShareSecret(
identity.getKeyPair().secretKey,
theirPublicKey.toRaw(),
);
final sharedX = sharedPoint.sublist(0, 32);
final decryptedMessage256 = await _decryptPhraseAsync256(
key: sharedX,
iv: base64Decode(iv),
cipherText: base64Decode(emsg),
);
return decryptedMessage256.u8aToString();
}