<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HPKE/Recipient",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Apple CryptoKit",
      "CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4HPKEO9RecipientV"
  },
  "title" : "HPKE.Recipient"
}
-->

# HPKE.Recipient

A type that represents the receiving side of an HPKE message exchange.

```
struct Recipient
```

## Overview

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(_:)`](/documentation/CryptoKit/HPKE/Recipient/open(_:)) or [`open(_:authenticating:)`](/documentation/CryptoKit/HPKE/Recipient/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.

## Topics

### Initializers

[`init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data) throws`](/documentation/CryptoKit/HPKE/Recipient/init(privateKey:ciphersuite:info:encapsulatedKey:)-6jqhf)

Creates a recipient in base mode.

[`init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data) throws`](/documentation/CryptoKit/HPKE/Recipient/init(privateKey:ciphersuite:info:encapsulatedKey:)-7v86b)

Creates a recipient in base mode.

[`init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data, authenticatedBy: SK.PublicKey) throws`](/documentation/CryptoKit/HPKE/Recipient/init(privateKey:ciphersuite:info:encapsulatedKey:authenticatedBy:))

Creates a recipient in authentication mode.

[`init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data, authenticatedBy: SK.PublicKey, presharedKey: SymmetricKey, presharedKeyIdentifier: Data) throws`](/documentation/CryptoKit/HPKE/Recipient/init(privateKey:ciphersuite:info:encapsulatedKey:authenticatedBy:presharedKey:presharedKeyIdentifier:))

Creates a recipient in authentication and preshared key mode.

[`init<SK>(privateKey: SK, ciphersuite: HPKE.Ciphersuite, info: Data, encapsulatedKey: Data, presharedKey: SymmetricKey, presharedKeyIdentifier: Data) throws`](/documentation/CryptoKit/HPKE/Recipient/init(privateKey:ciphersuite:info:encapsulatedKey:presharedKey:presharedKeyIdentifier:))

Creates a recipient in preshared key (PSK) mode.

### Instance Methods

[`func exportSecret<Context>(context: Context, outputByteCount: Int) throws -> SymmetricKey`](/documentation/CryptoKit/HPKE/Recipient/exportSecret(context:outputByteCount:))

Exports a secret given domain-separation context and the desired output length.

[`func open<C>(C) throws -> Data`](/documentation/CryptoKit/HPKE/Recipient/open(_:))

Decrypts a message, if the ciphertext is valid.

[`func open<C, AD>(C, authenticating: AD) throws -> Data`](/documentation/CryptoKit/HPKE/Recipient/open(_:authenticating:))

Decrypts a message, if the ciphertext is valid, verifying the integrity of additional authentication data.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)