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

# SecureEnclave.P256.KeyAgreement.PrivateKey

A P-256 private key used for key agreement.

```
struct PrivateKey
```

## Topics

### Creating a private key

[`init(dataRepresentation: Data, authenticationContext: LAContext?) throws`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/init(dataRepresentation:authenticationContext:))

Creates a P-256 private key for key agreement from a data
representation of the key with the given authentication
context.

[`init(compactRepresentable: Bool, accessControl: SecAccessControl, authenticationContext: LAContext?) throws`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/init(compactRepresentable:accessControl:authenticationContext:))

Creates a P-256 private key for key agreement with the
specified access control.

### Representing the key

[`let dataRepresentation: Data`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/dataRepresentation)

A data representation of the private key.

### Finding the public key

[`let publicKey: P256.KeyAgreement.PublicKey`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/publicKey)

The corresponding public key.

### Creating a shared secret

[`func sharedSecretFromKeyAgreement(with: P256.KeyAgreement.PublicKey) throws -> SharedSecret`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/sharedSecretFromKeyAgreement(with:))

Computes a shared secret with the provided public key from another
party.

[`struct SharedSecret`](/documentation/CryptoKit/SharedSecret)

A key agreement result from which you can derive a symmetric cryptographic
key.

### Initializers

[`init(compactRepresentable: Bool, accessControl: SecAccessControl) throws`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/init(compactRepresentable:accessControl:))

Creates a P-256 private key for key agreement with the
specified access control.

[`init(dataRepresentation: Data) throws`](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/init(dataRepresentation:))

Creates a P-256 private key for key agreement from the
specified data representation.

### Default Implementations

[DiffieHellmanKeyAgreement Implementations](/documentation/CryptoKit/SecureEnclave/P256/KeyAgreement/PrivateKey/DiffieHellmanKeyAgreement-Implementations)

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)