openBase static method

Future<Uint8List> openBase({
  1. required TspDecryptionKey recipient,
  2. required Uint8List enc,
  3. required List<int> info,
  4. required List<int> aad,
  5. required List<int> ciphertext,
})

Single-shot OpenBase(enc, skR, info, aad, ct).

Implementation

static Future<Uint8List> openBase({
  required TspDecryptionKey recipient,
  required Uint8List enc,
  required List<int> info,
  required List<int> aad,
  required List<int> ciphertext,
}) async {
  if (enc.length != recipient.kem.encLength) {
    throw TspDecryptionException(
      'encapsulated key is ${enc.length} bytes, expected ${recipient.kem.encLength}',
    );
  }
  final sharedSecret = await recipient.decapsulate(enc);
  final schedule = keySchedule(
    kemId: recipient.kem.id,
    sharedSecret: sharedSecret,
    info: info,
  );
  return ChaCha20Poly1305.open(
    key: schedule.key,
    nonce: schedule.baseNonce,
    aad: aad,
    ciphertextAndTag: ciphertext,
  );
}