decapsulate method
Recover the shared secret from ciphertext using secretKey.
Implementation
@override
Future<Uint8List> decapsulate(
Uint8List secretKey, Uint8List ciphertext) async {
XWingCore.checkDecapsulationInputs(secretKey, ciphertext);
final ct = XWingCore.splitCiphertext(ciphertext);
final _Expanded e = await _expand(secretKey);
try {
final Uint8List ssM =
await _mlKem.decapsulate(e.mlKemKeyPair.secretKey, ct.mlKem);
final Uint8List ssX = await _x25519.dh(e.x25519Secret, ct.x25519);
return XWingCore.combine(ssM, ssX, ct.x25519, e.x25519Public);
} finally {
_mlKem.releaseKeyPair(e.mlKemKeyPair);
}
}