encryptSharedSecret method

Future<List<int>> encryptSharedSecret(
  1. List<int> bytes,
  2. String recipientPublicKey
)

Encrypts shared secret bytes to share with the remote recipient using their encryption public key and the current peer's encryption private key.

Implementation

Future<List<int>> encryptSharedSecret(
  List<int> bytes,
  String recipientPublicKey,
) async {
  final sharedSecret = await _algorithm.sharedSecretKey(
    keyPair: _keyPair,
    remotePublicKey: parsePublicKey(recipientPublicKey),
  );

  final secretKey = await _kdf.deriveKey(
    secretKey: await sharedSecret.extract(),
    info: _kdfInfoVersion,
  );
  final secretBox = await _cipher.encrypt(bytes, secretKey: secretKey);

  return secretBox.concatenation();
}