<!--
{
  "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/HPKEPublicKeySerialization",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit26HPKEPublicKeySerializationP"
  },
  "title" : "HPKEPublicKeySerialization"
}
-->

# HPKEPublicKeySerialization

A type that [`HPKE`](/documentation/CryptoKit/HPKE) uses to encode the public key.

```
@preconcurrency protocol HPKEPublicKeySerialization : Sendable
```

## Topics

### Initializers

[`init<D>(D, kem: HPKE.KEM) throws`](/documentation/CryptoKit/HPKEPublicKeySerialization/init(_:kem:))

Creates a public key from an encoded representation.

### Instance Methods

[`func hpkeRepresentation(kem: HPKE.KEM) throws -> Data`](/documentation/CryptoKit/HPKEPublicKeySerialization/hpkeRepresentation(kem:))

Creates an encoded representation of the public key.

## Relationships

### Conforming Types

[`PublicKey`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey)

[`PublicKey`](/documentation/CryptoKit/XWingMLKEM768X25519/PublicKey)

[`PublicKey`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey)

[`PublicKey`](/documentation/CryptoKit/P384/KeyAgreement/PublicKey)

[`PublicKey`](/documentation/CryptoKit/Curve25519/KeyAgreement/PublicKey)

### Inherits From

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

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

### Inherited By

[`HPKEDiffieHellmanPublicKey`](/documentation/CryptoKit/HPKEDiffieHellmanPublicKey)

[`HPKEKEMPublicKey`](/documentation/CryptoKit/HPKEKEMPublicKey)

---

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)