decode method
Implementation
@override
Future<String?> decode(
String topic,
String encoded, {
DecodeOptions? options,
}) async {
_checkInitialized();
final EncodingValidation params = utils.validateDecoding(
encoded,
receiverPublicKey: options?.receiverPublicKey,
);
if (utils.isTypeTwoEnvelope(params)) {
return utils.decodeTypeTwoEnvelope(message: encoded);
}
if (utils.isTypeOneEnvelope(params)) {
final String selfPublicKey = params.receiverPublicKey!;
final String peerPublicKey = params.senderPublicKey!;
topic = await generateSharedKey(selfPublicKey, peerPublicKey);
}
final String? symKey = _getSymKey(topic);
if (symKey == null) {
return null;
}
final String message = await utils.decrypt(symKey, encoded);
return message;
}