makeSharedKey function

Future<List<int>> makeSharedKey(
  1. List<int> privateKey,
  2. List<int> publicKey
)

Makes a 32-byte shared key from the private key and the public key. Returns a Future that completes with the shared key.

Implementation

Future<List<int>> makeSharedKey(
  List<int> privateKey,
  List<int> publicKey,
) async {
  final algorithm = X25519();
  final sharedSecretKey = await algorithm.sharedSecretKey(
    keyPair: await algorithm.newKeyPairFromSeed(privateKey),
    remotePublicKey: SimplePublicKey(publicKey, type: KeyPairType.x25519),
  );
  return sharedSecretKey.extractBytes();
}