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

# P256.Signing.PrivateKey

A P-256 private key used to create cryptographic signatures.

```
struct PrivateKey
```

## Topics

### Creating a private key

[`init(rawRepresentation:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/init(rawRepresentation:))

Creates a P-256 private key for signing from a collection of bytes.

[`init(compactRepresentable:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/init(compactRepresentable:))

Creates a random P-256 private key for signing.

[`init(derRepresentation:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/init(derRepresentation:))

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

[`init(pemRepresentation:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/init(pemRepresentation:))

Creates a P-256 private key for signing from a Privacy-Enhanced Mail
PEM) representation.

[`init(x963Representation:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/init(x963Representation:))

Creates a P-256 private key for signing from an ANSI x9.63
representation.

### Representing the key

[`rawRepresentation`](/documentation/CryptoKit/P256/Signing/PrivateKey/rawRepresentation)

A data representation of the private key.

[`derRepresentation`](/documentation/CryptoKit/P256/Signing/PrivateKey/derRepresentation)

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

[`pemRepresentation`](/documentation/CryptoKit/P256/Signing/PrivateKey/pemRepresentation)

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

[`x963Representation`](/documentation/CryptoKit/P256/Signing/PrivateKey/x963Representation)

An ANSI x9.63 representation of the private key.

### Finding the public key

[`publicKey`](/documentation/CryptoKit/P256/Signing/PrivateKey/publicKey)

The corresponding public key.

### Creating a signature

[`signature(for:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/signature(for:)-5h94p)

Generates an Elliptic Curve Digital Signature Algorithm (ECDSA)
signature of the data you provide over the P-256 elliptic curve,
using SHA-256 as the hash function.

[`signature(for:)`](/documentation/CryptoKit/P256/Signing/PrivateKey/signature(for:)-1iyzc)

Generates an Elliptic Curve Digital Signature Algorithm (ECDSA)
signature of the digest you provide over the P-256 elliptic curve.

[`P256.Signing.ECDSASignature`](/documentation/CryptoKit/P256/Signing/ECDSASignature)

A P-256 elliptic curve digital signature algorithm (ECDSA) signature.



---

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)