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:
Function | Description | Arguments | Async | return |
---|---|---|---|---|
generate_new_share | generate a new Share with security question | threshold_key: ThresholdKey, questions: String, answer: String | Yes | GenerateShareStoreResult |
input_share | input share from security question | threshold_key: ThresholdKey, answer: String | Yes | Bool |
change_question_and_answer | Get private Key accounts | threshold_key: ThresholdKey, questions: String, answer: String | Yes | Bool |
store_answer | Store answer of security question in tKey | threshold_key: ThresholdKey, answer: String | Yes | Bool |
get_answer | Get answer of security question stored in tKey | threshold_key: ThresholdKey | No | String |
get_questions | Get security questions stored in tKey | threshold_key: ThresholdKey | No | String |
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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey object representing the key for which to generate a new share. |
questions | String | A String representing the user's security question. |
answer | String | A 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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey instance for which to input a share. |
answer | String | A 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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey instance for which to change the security questions and answers. |
questions | String | A String representing a new set of security questions to be answered. |
answer | String | A 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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A ThresholdKey instance for which to store the answer to a security question. |
answer | String | A 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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A 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
Parameters | Type | Description |
---|---|---|
threshold_key | ThresholdKey | A 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.