<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeviceCheck",
  "identifier" : "/documentation/DeviceCheck/DCError-swift.struct/Code/invalidKey",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "DeviceCheck"
    ],
    "preciseIdentifier" : "c:@E@DCError@DCErrorInvalidKey"
  },
  "title" : "DCError.Code.invalidKey"
}
-->

# DCError.Code.invalidKey

An error caused by a failed attempt to use the App Attest key.

```
case invalidKey
```

## Discussion

You receive this error if something goes wrong with generating,
retrieving, or using an App Attest cryptographic key, when:

- You call
  [`attestKey(_:clientDataHash:completionHandler:)`](/documentation/DeviceCheck/DCAppAttestService/attestKey(_:clientDataHash:completionHandler:))
  for a key that’s already been attested.
- You call
  [`generateAssertion(_:clientDataHash:completionHandler:)`](/documentation/DeviceCheck/DCAppAttestService/generateAssertion(_:clientDataHash:completionHandler:))
  with an unattested key.
- The App Attest service cannot enforce the key access control policy on macOS.
- The App Attest service rejects the key.

---

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)