sharedSecretKey method
Calculates a shared SecretKey.
Example
In this example, we use X25519:
import 'package:cryptography/cryptography.dart';
Future<void> main() async {
final algorithm = X25519();
// We need the private key pair of Alice.
final aliceKeyPair = await algorithm.newKeyPair();
// We need only public key of Bob.
final bobKeyPair = await algorithm.newKeyPair();
final bobPublicKey = await bobKeyPair.extractPublicKey();
// We can now calculate a 32-byte shared secret key.
final sharedSecretKey = await algorithm.sharedSecretKey(
keyPair: aliceKeyPair,
remotePublicKey: bobPublicKey,
);
}
Implementation
@override
Future<SecretKey> sharedSecretKey({
required KeyPair keyPair,
required PublicKey remotePublicKey,
}) {
throw UnimplementedError();
}