decryptPayload method

Map decryptPayload({
  1. required String data,
  2. required String nonce,
})

Decrypts the data payload returned by Phantom Wallet

  • Using nonce we generated on server side and _dAppSecretKey we decrypt the encrypted data.
  • Returns the decrypted payload as a Map<dynamic, dynamic>.

Implementation

Map<dynamic, dynamic> decryptPayload({
  required String data,
  required String nonce,
}) {
  if (_sharedSecret == null) {
    return <String, String>{};
  }

  final decryptedData = _sharedSecret?.decrypt(
    ByteList(base58decode(data)),
    nonce: Uint8List.fromList(base58decode(nonce)),
  );

  Map payload =
      const JsonDecoder().convert(String.fromCharCodes(decryptedData!));
  return payload;
}