sharedSecretKey method
Calculates a shared SecretKey
.
Implementation
@override
Future<SecretKey> sharedSecretKey({
required KeyPair keyPair,
required PublicKey remotePublicKey,
}) async {
if (!kIsWeb) {
if (isSupportedPlatform &&
keyPair is SimpleKeyPairData &&
remotePublicKey is SimplePublicKey) {
final privateKey = await keyPair.extractPrivateKeyBytes();
final publicKey = remotePublicKey.bytes;
final result = await invokeMethod('X25519.sharedSecretKey', {
'privateKey': asUint8List(privateKey),
'publicKey': asUint8List(publicKey),
});
return SecretKey(
result['sharedSecretKey'] as Uint8List,
);
}
}
return await fallback.sharedSecretKey(
keyPair: keyPair,
remotePublicKey: remotePublicKey,
);
}