Skip to main content

Share Transfer Module - tKey iOS SDK

The ShareTransferModule is a Swift module that provides functions for requesting, approving and transfering a share to another device.

To use the ShareTransferModule in your Swift project, you will need to import the module as follows:

import tkey_pkg

ShareTransferModule is a class that provides the following methods:

FunctionDescriptionArgumentsAsyncreturn
request_new_sharerequest a new sharethreshold_key: ThresholdKey, user_agent: String, available_share_indexes: StringYesString
add_custom_info_to_requestAdd custom info to share requestthreshold_key: ThresholdKey, enc_pub_key_x: String, custom_info: StringYesvoid
look_for_requestReturns an array of indexes of pending requeststhreshold_key: ThresholdKey Yes[String]
approve_requestapprove the shareStore to be sharedthreshold_key: ThresholdKey, enc_pub_key_x: String, share_store: ShareStoreYesvoid
approve_request_with_share_indexapprove sharing with share indexthreshold_key: ThresholdKey, enc_pub_key_x: String, share_index: StringYesvoid
get_storeGet share transfer storethreshold_key: ThresholdKeyYesShareTransferStore
set_storeSet share transfer storethreshold_key: ThresholdKey, store: ShareTransferStoreYesBool
delete_storeDelete share transfer storethreshold_key: ThresholdKey, enc_pub_key_x: StringYesBool
get_current_encryption_keyGet security questions stored in tKeythreshold_key: ThresholdKeyNoString
request_status_checkstart request status checkingthreshold_key: ThresholdKey, enc_pub_key_x: String, delete_request_on_completion: BoolYesShareStore
cleanup_requestcleanup the requestthreshold_key: ThresholdKeyNoBool

request_new_share()

request_new_share(threshold_key: ThresholdKey, user_agent: String, available_share_indexes: String ) async throws -> String

Request a new share for the given user.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
user_agentStringA string representing the user's user agent.
available_share_indexesStringA string representing the available share indexes for the user.

Returns

  • String: A string representing the requested share.

add_custom_info_to_request()

add_custom_info_to_request(threshold_key: ThresholdKey, enc_pub_key_x: String, custom_info: String ) async throws

Adds custom information to a share request.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
enc_pub_key_xStringA string representing the user's encryption public key.
custom_infoStringA string representing the custom information to add to the request.

look_for_request()

look_for_request(threshold_key: ThresholdKey ) async throws -> [String]

Check the status of the user's share request.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.

Returns

  • [String]: An array of strings representing the status of the user's share request.

approve_request()

approve_request(threshold_key: ThresholdKey, enc_pub_key_x: String, share_store: ShareStore ) async throws

Approves a share request for the user.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
enc_pub_key_xStringA string representing the user's encryption public key.
share_storeShareStoreA ShareStore object representing the user's share store.

approve_request_with_share_index()

approve_request_with_share_index(threshold_key: ThresholdKey, enc_pub_key_x: String, share_index: String ) async throws

Approves a share request for the user using a specific share index.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
enc_pub_key_xStringA string representing the user's encryption public key.
share_indexStringA string representing the specific share index to use for the share request.

get_store()

get_store(threshold_key: ThresholdKey ) async throws -> ShareTransferStore

Get the user's share store.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.

Returns

  • ShareTransferStore: A ShareTransferStore object representing the user's share store.

set_store()

set_store(threshold_key: ThresholdKey, store: ShareTransferStore ) async throws -> Bool

Set the user's share store.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
storeShareTransferStoreA ShareTransferStore object representing the user's share store.

Returns

  • Bool: A boolean value indicating whether the operation was successful.

delete_store()

delete_store(threshold_key: ThresholdKey, enc_pub_key_x: String ) async throws -> Bool

Delete the user's share store.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
enc_pub_key_xStringA string representing the user's encryption public key.

Returns

  • Bool: A boolean value indicating whether the operation was successful.

get_current_encryption_key()

get_current_encryption_key(threshold_key: ThresholdKey) throws -> String

This method is used to get the current encryption key for the given threshold_key.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.

Returns

  • String: A string value representing the current encryption key.

Throws

  • ShareTransferError: If there is an issue with the underlying share transfer module.
  • RuntimeError: If there is an issue with the runtime environment.

request_status_check()

request_status_check(threshold_key: ThresholdKey, enc_pub_key_x: String, delete_request_on_completion: Bool ) async throws -> ShareStore

This method is used to check the status of a request for the specified enc_pub_key_x under the given threshold_key.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.
enc_pub_key_xStringA string representing the user's encryption public key.
delete_request_on_completionBoolA boolean value indicating whether the request should be deleted upon completion.

Returns

  • ShareStore: A ShareStore object representing the current status of the request.

Throws

  • ShareTransferError: If there is an issue with the underlying share transfer module.
  • RuntimeError: If there is an issue with the runtime environment.

cleanup_request()

cleanup_request(threshold_key: ThresholdKey) throws

This method is used to clean up any remaining requests for the specified threshold_key.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the user's threshold key.

Returns

  • Void

Throws

  • ShareTransferError: If there is an issue with the underlying share transfer module.
  • RuntimeError: If there is an issue with the runtime environment.