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

# Curve25519.KeyAgreement.PrivateKey

A Curve25519 private key used for key agreement.

```
struct PrivateKey
```

## Topics

### Creating a private key

[`init()`](/documentation/CryptoKit/Curve25519/KeyAgreement/PrivateKey/init())

Creates a random Curve25519 private key for key agreement.

[`init(rawRepresentation:)`](/documentation/CryptoKit/Curve25519/KeyAgreement/PrivateKey/init(rawRepresentation:))

Creates a Curve25519 private key for key agreement from a
collection of bytes.

### Reporting the private key

[`rawRepresentation`](/documentation/CryptoKit/Curve25519/KeyAgreement/PrivateKey/rawRepresentation)

The raw representation of the key as a collection of contiguous
bytes.

### Finding the public key

[`publicKey`](/documentation/CryptoKit/Curve25519/KeyAgreement/PrivateKey/publicKey)

The corresponding public key.

### Creating a shared secret

[`sharedSecretFromKeyAgreement(with:)`](/documentation/CryptoKit/Curve25519/KeyAgreement/PrivateKey/sharedSecretFromKeyAgreement(with:))

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

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

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

## Relationships

### Conforms To

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

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

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

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

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

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

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