sharedSecretKey abstract method

Future<SecretKey> sharedSecretKey({
  1. required PublicKey remotePublicKey,
})

Computes the shared secret key that this and the other party can compute using public keys known to each other.

Example

import 'package:cryptography/cryptography.dart';

Future<void> main() async {
  final x25519 = X25519();

  // Alice has her private key.
  final aliceWand = await x25519.newKeyExchangeWand();

  // Bob gives his public key to Alice.
  final bobPublicKey = await (await x25519.newKeyPair()).extractPublicKey();

  // Alice can now compute a shared secret key.
  // If Bob does the same, he will get the same key.
  // Other parties cannot compute the same key.
  final secretKey = await aliceWand.sharedSecretKey(
    remotePublicKey: bobPublicKey,
  );
}

Implementation

Future<SecretKey> sharedSecretKey({
  required PublicKey remotePublicKey,
});