<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/P521/KeyAgreement/PublicKey",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4P521O12KeyAgreementO06PublicD0V"
  },
  "title" : "P521.KeyAgreement.PublicKey"
}
-->

# P521.KeyAgreement.PublicKey

A P-521 public key used for key agreement.

```
struct PublicKey
```

## Topics

### Creating a public key

[`init<D>(rawRepresentation: D) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(rawRepresentation:))

Creates a P-521 public key for key agreement from a collection of bytes.

[`init<Bytes>(compactRepresentation: Bytes) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(compactRepresentation:))

Creates a P-521 public key for key agreement from a compact
representation of the key.

[`init<Bytes>(derRepresentation: Bytes) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(derRepresentation:))

Creates a P-521 public key for key agreement from a Distinguished Encoding
Rules (DER) encoded representation.

[`init(pemRepresentation: String) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(pemRepresentation:))

Creates a P-521 public key for key agreement from a Privacy-Enhanced Mail
(PEM) representation.

[`init<Bytes>(x963Representation: Bytes) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(x963Representation:))

Creates a P-521 public key for key agreement from an ANSI x9.63
representation.

[`init<Bytes>(compressedRepresentation: Bytes) throws`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/init(compressedRepresentation:))

Creates a P-521 public key for key agreement from a compressed representation of
the key.

### Representing the key

[`var rawRepresentation: Data`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/rawRepresentation)

A full representation of the public key.

[`var compactRepresentation: Data?`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/compactRepresentation)

A compact representation of the public key.

[`var derRepresentation: Data`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/derRepresentation)

A Distinguished Encoding Rules (DER) encoded representation of the public key.

[`var pemRepresentation: String`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/pemRepresentation)

A Privacy-Enhanced Mail (PEM) representation of the public key.

[`var x963Representation: Data`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/x963Representation)

An ANSI x9.63 representation of the public key.

[`var compressedRepresentation: Data`](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/compressedRepresentation)

A compressed representation of the public key.

### Type Aliases

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

The type of the ephemeral private key associated with this public key.

### Default Implementations

[HPKEDiffieHellmanPublicKey Implementations](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/HPKEDiffieHellmanPublicKey-Implementations)

[HPKEPublicKeySerialization Implementations](/documentation/CryptoKit/P521/KeyAgreement/PublicKey/HPKEPublicKeySerialization-Implementations)

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)