Skip to main content

Security Question Module - tKey iOS SDK

SecurityQuestionModule is a Swift module that provides functionality for setting, changing, getting, and deleting security question and password for a ThresholdKey object.

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

import tkey_pkg

SecurityQuestionModule is a class that provides the following methods:

FunctionDescriptionArgumentsAsyncreturn
generate_new_sharegenerate a new Share with security questionthreshold_key: ThresholdKey, questions: String, answer: StringYesGenerateShareStoreResult
input_shareinput share from security questionthreshold_key: ThresholdKey, answer: StringYesBool
change_question_and_answerGet private Key accountsthreshold_key: ThresholdKey, questions: String, answer: StringYesBool
store_answerStore answer of security question in tKeythreshold_key: ThresholdKey, answer: StringYesBool
get_answerGet answer of security question stored in tKeythreshold_key: ThresholdKeyNoString
get_questionsGet security questions stored in tKeythreshold_key: ThresholdKeyNoString

generate_new_share()

generate_new_share(threshold_key: ThresholdKey, questions: String, answer: String ) async throws -> GenerateShareStoreResult

This function generates a new share for a given ThresholdKey, along with the user's security question and answer.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey object representing the key for which to generate a new share.
questionsStringA String representing the user's security question.
answerStringA String representing the user's security answer.

Returns

  • GenerateShareStoreResult: A struct that contains information about the new share that was generated.

Throws

  • Error: An error if the operation failed.

input_share()

input_share(threshold_key: ThresholdKey, answer: String ) async throws -> Bool

A method that inputs a share for a threshold key based on a security question and answer.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey instance for which to input a share.
answerStringA String representing the answer to the security questions.

Returns

  • Bool: true if the share was successfully input, false otherwise.

Throws

  • Error: An error if the operation failed.

change_question_and_answer()

change_question_and_answer(threshold_key: ThresholdKey, questions: String, answer: String ) async throws -> Bool

A method that changes the security questions and answers for a threshold key.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey instance for which to change the security questions and answers.
questionsStringA String representing a new set of security questions to be answered.
answerStringA String representing the answer to the security questions.

Returns

  • Bool: true if the security questions and answers were successfully changed, false otherwise.

Throws

  • Error: An error if the operation failed.

store_answer()

store_answer(threshold_key: ThresholdKey, answer: String ) async throws -> Bool

A method that stores the answer to a security question for a threshold key.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey instance for which to store the answer to a security question.
answerStringA String representing the answer to the security question.

Returns

  • Bool: true if the answer was successfully stored, false otherwise.

Throws

  • Error: An error if the operation failed.

get_answer()

get_answer(threshold_key: ThresholdKey) throws -> String

Get answer of security question stored in tKey.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey instance for which to store the answer to a security question.

Returns

  • String: A String representing the answer to the security questions.

Throws

  • Error: An error if the operation failed.

get_questions()

get_questions(threshold_key: ThresholdKey) throws -> String

This method gets security questions stored in tKey.

Parameters

ParametersTypeDescription
threshold_keyThresholdKeyA ThresholdKey instance for which to store the answer to a security question.

Returns

  • String: A String representing the user's security question.

Throws

  • Error: An error if the operation failed.