---
title: "init(_:kem:)"
framework: cryptokit
role: symbol
role_heading: Initializer
path: "cryptokit/p521/keyagreement/publickey/init(_:kem:)"
---

# init(_:kem:)

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

## Declaration

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

## Discussion

Discussion serialization: The serialized bytes of the public key. kem: The Key Encapsulation Mechanism to use with the public key. note: HPKE.Errors.inconsistentCiphersuiteAndKey if the key encapsulation mechanism requested is incompatible with this public key.
