sharedSecretSync method

  1. @override
SecretKey sharedSecretSync({
  1. required KeyPairData keyPairData,
  2. required PublicKey remotePublicKey,
})
override

Implementation

@override
SecretKey sharedSecretSync({
  required KeyPairData keyPairData,
  required PublicKey remotePublicKey,
}) {
  if (keyPairData is! SimpleKeyPairData ||
      !KeyPairType.x25519.isValidKeyPairData(keyPairData)) {
    throw ArgumentError.value(
      keyPairData,
      'keyPairData',
    );
  }
  if (remotePublicKey is! SimplePublicKey ||
      !KeyPairType.x25519.isValidPublicKey(remotePublicKey)) {
    throw ArgumentError.value(
      remotePublicKey,
      'remotePublicKey',
    );
  }
  final privateKeyBytes = modifiedPrivateKeyBytes(keyPairData.bytes);
  final result = Uint8List(32);
  _calculate(
    result,
    privateKeyBytes,
    Uint8List.fromList(remotePublicKey.bytes),
  );
  return SecretKey(List<int>.unmodifiable(result));
}