<!--
{
  "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/P521/KeyAgreement/PublicKey/init(_:kem:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Apple CryptoKit",
      "CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4P521O12KeyAgreementO06PublicD0V_3kemAGx_AA4HPKEO3KEMOtKc10Foundation15ContiguousBytesRzlufc"
  },
  "title" : "init(_:kem:)"
}
-->

# init(_:kem:)

Creates a NIST P-521 elliptic curve public key for use with Diffie-Hellman key exchange.

```
init<D>(_ serialization: D, kem: HPKE.KEM) throws where D : ContiguousBytes
```

## Discussion

- serialization: The serialized bytes of the public key.
- kem: The Key Encapsulation Mechanism to use with the public key.

> Throws: ``doc://com.apple.CryptoKit/documentation/CryptoKit/HPKE/Errors/inconsistentCiphersuiteAndKey`` if the key encapsulation mechanism requested is incompatible with this public key.

---

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)