createSession method
Creates _sharedSecret using _dAppSecretKey and phantom_encryption_public_key.
Once _sharedSecret is created, it can be used to encrypt and decrypt data.
Here we decrypt the data using _sharedSecret and nonce to get _sessionToken and userPublicKey.
Refer to (Encryption)https://docs.phantom.app/integrating/deeplinks-ios-and-android/encryption to learn how apps can decrypt data using a shared secret. Encrypted bytes are encoded in base58.
Implementation
bool createSession(Map<String, String> params) {
try {
createSharedSecret(Uint8List.fromList(
base58decode(params["phantom_encryption_public_key"]!)));
var dataDecrypted =
decryptPayload(data: params["data"]!, nonce: params["nonce"]!);
_sessionToken = dataDecrypted["session"];
userPublicKey = dataDecrypted["public_key"];
} catch (e) {
return false;
}
return true;
}