preparePGPPublicKey function
Implementation
Future<String> preparePGPPublicKey({
String encryptionType = Constants.ENC_TYPE_V3,
required String generatedPublicKey,
required Wallet wallet,
}) async {
String chatPublicKey;
switch (encryptionType) {
case Constants.ENC_TYPE_V1:
{
chatPublicKey = generatedPublicKey;
break;
}
case Constants.ENC_TYPE_V3:
{
final createProfileMessage =
'Create Push Profile \n${generateHash(generatedPublicKey)}';
final signature =
await getEip191Signature(wallet, createProfileMessage);
chatPublicKey = jsonEncode({
'key': generatedPublicKey,
'signature': signature['verificationProof'],
});
break;
}
case Constants.ENC_TYPE_V4:
{
final createProfileMessage =
'Create Push Profile \n${generateHash(generatedPublicKey)}';
final signature =
await getEip191Signature(wallet, createProfileMessage);
chatPublicKey = jsonEncode({
'key': generatedPublicKey,
'signature': signature['verificationProof'],
});
break;
}
default:
throw Exception('Invalid Encryption Type');
}
return chatPublicKey;
}