decode method
Future
decode({
- required String topic,
- required String encoded,
- CryptoDecodeOptions? opts,
override
Implementation
@override
Future<dynamic> decode({
required String topic,
required String encoded,
CryptoDecodeOptions? opts,
}) async {
_isInitialized();
final params = utils.validateDecoding(encoded: encoded, opts: opts);
if (utils.isTypeOneEnvelope(params)) {
final selfPublicKey = params.receiverPublicKey!;
final peerPublicKey = params.senderPublicKey!;
topic = await generateSharedKey(
selfPublicKey: selfPublicKey,
peerPublicKey: peerPublicKey,
);
}
final symKey = _getSymKey(topic);
final message = await utils.decrypt(symKey: symKey, encoded: encoded);
final payload = jsonDecode(message);
return payload;
}