It would be good to add an API for KEM (Key Encapsulation Mechanism).
Unfortunately, even in the standardization, there is no consensus for the abstraction (yet).
Here are some references from IETF.
RFC 5990: Use of RSA-KEM Key Transport Algorithm in the Cryptographic Message Syntax (CMS):
https://www.rfc-editor.org/rfc/rfc5990.html
- It also has key wrapping process
RFC 9180: Hybrid Public Key Encryption: https://www.rfc-editor.org/rfc/rfc9180.html
IETF draft: Using Key Encapsulation Mechanism (KEM) Algorithms in the Cryptographic Message Syntax (CMS):
https://www.ietf.org/archive/id/draft-ietf-lamps-cms-kemri-05.html
IETF draft: Streamlined NTRU Prime: sntrup761
https://www.ietf.org/archive/id/draft-josefsson-ntruprime-streamlined-00.html
IETF draft: Kyber Post-Quantum KEM
https://www.ietf.org/archive/id/draft-cfrg-schwabe-kyber-03.html
For an API candidate, we could consider that three functions are somehow common (among those standardization above):
Citing from draft-ietf-lamps-cms-kemri-05:
- KeyGen() -> (pk, sk):
Generate the public key (pk) and a private key (sk).
- Encapsulate(pk) -> (ct, ss):
Given the recipient's public key (pk), produce a ciphertext (ct) to be passed to the recipient and shared secret (ss) for the originator.
- Decapsulate(sk, ct) -> ss:
Given the private key (sk) and the ciphertext (ct), produce the shared secret (ss) for the recipient.