One Logo Pool Ball
CryptoKit · IOS API REFERENCE

HPKE.Recipient

struct · iOS 17.0+ · SDK 27.1

struct Recipient

A type that represents the receiving side of an HPKE message exchange. To decrypt and verify the identity of encrypted messages, initialize a `Recipient` specifying the appropriate cipher suite, the receiver's private key, the encapsulated symmetric key, and the additional cryptographic material relevant to your chosen mode of operation. Call ``open(_:)`` or ``open(_:authenticating:)`` on the `Recipient` instance for each message in turn to retrieve its cleartext. The recipient of the messages needs to process them in the same order as the `Sender`, using the same cipher suite, encryption mode, and key schedule information (`info` data). Use a separate `Recipient` instance for each stream of messages.

Members (4)

init · iOS 26.0+

init

TypeScript
static init(privateKey: XWingMLKEM768X25519_PrivateKey, ciphersuite: HPKE_Ciphersuite, info: ArrayBuffer, encapsulatedKey: ArrayBuffer): HPKE_Recipient
Swift declaration
init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data) throws where SK : HPKEKEMPrivateKey

Creates a recipient in base mode. The `Receiver` decrypts messages in base mode using the encapsulated key with the key schedule information (`info` data). - Parameters: - privateKey: The recipient's private key for decrypting the incoming messages. - ciphersuite: The cipher suite that defines the cryptographic algorithms to use. - info: Data that the key derivation function uses to compute the symmetric key material. The sender and the recipient need to use the same `info` data. - encapsulatedKey: The encapsulated symmetric key that the sender provides. - Note: The system throws errors from ``CryptoKit/HPKE/Errors`` when it encounters them.

method · iOS 17.0+

exportSecret

TypeScript
exportSecret(context: ArrayBuffer, outputByteCount: number): SymmetricKey
Swift declaration
func exportSecret<Context>(context: Context, outputByteCount: Int) throws -> SymmetricKey where Context : DataProtocol

Exports a secret given domain-separation context and the desired output length. - Parameters: - context: Application-specific information providing context on the use of this key. - outputByteCount: The desired length of the exported secret. - Returns: The exported secret.

method · iOS 17.0+

open

TypeScript
openAuthenticating(ciphertext: ArrayBuffer, aad: ArrayBuffer): ArrayBuffer
Swift declaration
mutating func open<C, AD>(_ ciphertext: C, authenticating aad: AD) throws -> Data where C : DataProtocol, AD : DataProtocol

Decrypts a message, if the ciphertext is valid, verifying the integrity of additional authentication data. You can call this method multiple times to decrypt a series of messages. When using this method, the recipient of the ciphertext messages needs to decrypt them in the same order that the sender encrypts them. The system doesn't decrypt the additional authentication data in the `aad` parameter that the recipient uses to verify the message integrity. - Parameters: - ciphertext: The ciphertext message to decrypt. - aad: Additional cleartext data to authenticate. - Note: The system throws errors from ``CryptoKit/HPKE/Errors`` when it encounters them. - Returns: The resulting cleartext message if the message is authentic.

method · iOS 17.0+

open

TypeScript
open(ciphertext: ArrayBuffer): ArrayBuffer
Swift declaration
mutating func open<C>(_ ciphertext: C) throws -> Data where C : DataProtocol

Decrypts a message, if the ciphertext is valid. You can call this method multiple times to decrypt a series of messages. When using this method, the recipient of the ciphertext messages needs to decrypt them in the same order that the sender encrypts them. - Parameters: - ciphertext: The ciphertext message to decrypt. - Note: The system throws errors from ``CryptoKit/HPKE/Errors`` when it encounters them. - Returns: The resulting cleartext message if the message is authentic.

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

HPKE.Recipient.init(privateKey:ciphersuite:info:encapsulatedKey:)

This declaration needs Swift generic type arguments. (no canonical witness for SK)

HPKE.Recipient.init(privateKey:ciphersuite:info:encapsulatedKey:presharedKey:presharedKeyIdentifier:)

This declaration needs Swift generic type arguments. (no canonical witness for SK)

HPKE.Recipient.init(privateKey:ciphersuite:info:encapsulatedKey:authenticatedBy:)

This declaration needs Swift generic type arguments. (no canonical witness for SK)

HPKE.Recipient.init(privateKey:ciphersuite:info:encapsulatedKey:authenticatedBy:presharedKey:presharedKeyIdentifier:)

This declaration needs Swift generic type arguments. (no canonical witness for SK)

All CryptoKit types →