<!--
{
  "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/P256/KeyAgreement/PublicKey",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4P256O12KeyAgreementO06PublicD0V"
  },
  "title" : "P256.KeyAgreement.PublicKey"
}
-->

# P256.KeyAgreement.PublicKey

A P-256 public key used for key agreement.

```
struct PublicKey
```

## Topics

### Creating a public key

[`init(rawRepresentation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(rawRepresentation:))

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

[`init(compactRepresentation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(compactRepresentation:))

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

[`init(derRepresentation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(derRepresentation:))

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

[`init(pemRepresentation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(pemRepresentation:))

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

[`init(x963Representation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(x963Representation:))

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

[`init(compressedRepresentation:)`](/documentation/CryptoKit/P256/KeyAgreement/PublicKey/init(compressedRepresentation:))

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

### Representing the key

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

A full representation of the public key.

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

A compact representation of the public key.

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

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

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

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

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

An ANSI x9.63 representation of the public key.

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

A compressed representation of the public key.

## Relationships

### Conforms To

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

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

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

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

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

[`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)