Skip to main content

Security Question Module

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

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

import com.web3auth.tkey.ThresholdKey.ThresholdKey;
import com.web3auth.tkey.ThresholdKey.Modules.SecurityQuestionModule;

SecurityQuestionModule is a class that provides the following methods:

FunctionDescriptionArgumentsAsyncreturn
generateNewSharegenerate a new Share with security questionthresholdKey: ThresholdKey, questions: String, answer: StringYesGenerateShareStoreResult
inputShareinput share from security questionthresholdKey: ThresholdKey, answer: StringYesBool
changeSecurityQuestionAndAnswerGet private Key accountsthresholdKey: ThresholdKey, questions: String, answer: StringYesBool
storeAnswerStore answer of security question in tKeythresholdKey: ThresholdKey, answer: StringYesBool
getAnswerGet answer of security question stored in tKeythresholdKey: ThresholdKeyNoString
getQuestionsGet security questions stored in tKeythresholdKey: ThresholdKeyNoString

generateNewShare()

public static void generateNewShare(ThresholdKey thresholdKey, String questions, String answer, ThresholdKeyCallback<GenerateShareStoreResult> callback)

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

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA 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.

inputShare()

public static void inputShare(ThresholdKey thresholdKey, String answer, ThresholdKeyCallback<Boolean> callback)

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

Parameters

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

Returns

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

Throws

  • Error: An error if the operation failed.

changeSecurityQuestionAndAnswer()

public static void changeSecurityQuestionAndAnswer(ThresholdKey thresholdKey, String questions, String answer, ThresholdKeyCallback<Boolean> callback)

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

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA 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.

storeAnswer()

public static void storeAnswer(ThresholdKey thresholdKey, String answer, ThresholdKeyCallback<Boolean> callback)

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

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA 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.

getAnswer()

public static String getAnswer(ThresholdKey thresholdKey) throws RuntimeError

Get answer of security question stored in tKey.

Parameters

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

Returns

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

Throws

  • RuntimeError: An error if the operation failed.

getQuestions()

public static String getQuestions(ThresholdKey thresholdKey) throws RuntimeError

This method gets security questions stored in tKey.

Parameters

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

Returns

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

Throws

  • RuntimeError: An error if the operation failed.