<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoTokenKit",
  "identifier" : "/documentation/CryptoTokenKit/TKTokenSessionDelegate/tokenSession(_:sign:keyObjectID:algorithm:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CryptoTokenKit"
    ],
    "preciseIdentifier" : "c:objc(pl)TKTokenSessionDelegate(im)tokenSession:signData:usingKey:algorithm:error:"
  },
  "title" : "tokenSession(_:sign:keyObjectID:algorithm:)"
}
-->

# tokenSession(_:sign:keyObjectID:algorithm:)

Tells the delegate to sign a data object using the specified key and algorithm.

```
optional func tokenSession(_ session: TKTokenSession, sign dataToSign: Data, keyObjectID: TKToken.ObjectID, algorithm: TKTokenKeyAlgorithm) throws -> Data
```

## Parameters

`session`

The token session.

`dataToSign`

The data to sign.

`keyObjectID`

The identifier of the private key object.

`algorithm`

The algorithm to be used for signing.

## Return Value

The signed data, or `nil` if an error occurred.

---

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)