---
title: "tokenSession(_:performKeyExchange:keyObjectID:algorithm:parameters:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tktokensessiondelegate/tokensession(_:performkeyexchange:keyobjectid:algorithm:parameters:)"
---

# tokenSession(_:performKeyExchange:keyObjectID:algorithm:parameters:)

Tells the delegate to perform a key exchange using the specified key and algorithm.

## Declaration

```swift
optional func tokenSession(_ session: TKTokenSession, performKeyExchange otherPartyPublicKeyData: Data, keyObjectID objectID: TKToken.ObjectID, algorithm: TKTokenKeyAlgorithm, parameters: TKTokenKeyExchangeParameters) throws -> Data
```

## Parameters

- `session`: The token session.
- `otherPartyPublicKeyData`: The public key of the other party.
- `objectID`: The identifier of the private key object.
- `algorithm`: The algorithm to be used for key exchange.
- `parameters`: Additional parameters used by algorithm to perform the key exchange.

## Return Value

Return Value The result of the key exchange, or nil if an error occurred.

## See Also

### Performing Cryptographic Operations

- [tokenSession(_:sign:keyObjectID:algorithm:)](cryptotokenkit/tktokensessiondelegate/tokensession(_:sign:keyobjectid:algorithm:).md)
- [tokenSession(_:decrypt:keyObjectID:algorithm:)](cryptotokenkit/tktokensessiondelegate/tokensession(_:decrypt:keyobjectid:algorithm:).md)
- [TKTokenKeyExchangeParameters](cryptotokenkit/tktokenkeyexchangeparameters.md)
