deriveKey method

Key deriveKey({
  1. required KeyAlgorithm encryptionAlgorithm,
  2. required Key ephemeralKey,
  3. required Key senderKey,
  4. required Key recipientKey,
  5. required bool receive,
  6. Uint8List? ccTag,
})

Derives an ECDH-1PU shared key for authenticated encryption.

Throws an AskarKeyException if key derivation fails.

Implementation

Key deriveKey({
  required KeyAlgorithm encryptionAlgorithm,
  required Key ephemeralKey,
  required Key senderKey,
  required Key recipientKey,
  required bool receive,
  Uint8List? ccTag,
}) {
  try {
    return Key(
      askarKeyDeriveEcdh1pu(
        encryptionAlgorithm,
        ephemeralKey.handle,
        senderKey.handle,
        recipientKey.handle,
        algId,
        apu,
        apv,
        ccTag: ccTag,
        receive: receive,
      ).getValueOrException(),
    );
  } catch (e) {
    throw AskarKeyException('Failed to derive key: $e');
  }
}