<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeyCopyPublicKey(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeyCopyPublicKey"
  },
  "title" : "SecKeyCopyPublicKey(_:)"
}
-->

# SecKeyCopyPublicKey(_:)

Gets the public key associated with the given private key.

```
func SecKeyCopyPublicKey(_ key: SecKey) -> SecKey?
```

## Parameters

`key`

The private key for which you want the corresponding public key.

## Return Value

The public key corresponding to the given private key. In Objective-C, call the <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> function to free this key’s memory when you are done with it.

## Discussion

The returned public key may be `nil` if the app that created the private key didn’t also store the corresponding public key in the keychain, or if the system can’t reconstruct the corresponding public 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)