decode method

  1. @override
Future decode({
  1. required String topic,
  2. required String encoded,
  3. 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;
}