Generates and encapsulates a shared secret.
Share the encapsulated secret with the person who has the ``KEMPrivateKey``.
They use ``KEMPrivateKey/decapsulate(_:)`` to recover the shared secret.
- Returns: The shared secret, and its encapsulated version.
init<D>(rawRepresentation: D) throws where D : ContiguousBytes
method · iOS 26.0+
hpkeRepresentation
TypeScript
hpkeRepresentation(kem: HPKE_KEM): ArrayBuffer
Swift declaration
func hpkeRepresentation(kem: HPKE.KEM) throws -> Data
Creates a serialized representation of the public key.
- Parameters:
- kem: The Key Encapsulation Mechanism to use with the public key.
- Throws: ``CryptoKit/HPKE/Errors/inconsistentCiphersuiteAndKey`` if the key encapsulation mechanism requested is incompatible with this public key.
- Returns: The serialized representation of the public key.
init<D>(_ serialization: D, kem: HPKE.KEM) throws where D : ContiguousBytes
Creates an X-Wing public key for use with HPKE.
- Parameters:
- serialization: The serialized bytes of the public key.
- kem: The key encapsulation mechanism to use with the public key.
- Throws: ``CryptoKit/HPKE/Errors/inconsistentCiphersuiteAndKey`` if the key encapsulation mechanism requested is incompatible with this public key.