Skip to main content

Private Keys Module

The PrivateKeysModule module provides an interface for setting, getting and managing private keys for a ThresholdKey object.

To use the PrivateKeysModule 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.PrivateKeysModule;

PrivateKeysModule is a class that provides the following methods:

FunctionDescriptionArgumentsAsyncreturn
setPrivateKeySet private key to corresponding tKeythresholdKey: ThresholdKey, key: String?, format: StringYesBool
getPrivateKeysGet Private KeysthresholdKey: ThresholdKeyNo[[String:String]]
getPrivateKeyAccountsGet private Key accountsthresholdKey: ThresholdKeyNo[String]

setPrivateKey()

public static void setPrivateKey(ThresholdKey thresholdKey, @Nullable String key, String format, ThresholdKeyCallback<Boolean> callback)

Sets a private key for a ThresholdKey object.

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA ThresholdKey object.
keyString?A private key in hex-encoded/mnemonic string format
formatStringA string representing the format of the private key.

Returns

  • Bool: A boolean indicating whether the operation succeeded or not.

getPrivateKeys()

public static String getPrivateKeys(ThresholdKey thresholdKey) throws RuntimeError

Returns a list of private keys for a ThresholdKey object.

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA ThresholdKey object.

Returns

  • [[String:String]]: A list of private keys as dictionaries.

Throws

  • RuntimeError: If there is an error in during runtime.

getPrivateKeyAccounts()

public static ArrayList<String> getPrivateKeyAccounts(ThresholdKey thresholdKey) throws RuntimeError, JSONException

  • Returns a list of accounts for which private keys are available.

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA ThresholdKey object.

Returns

  • ArrayList<String>: A list of accounts for which private keys are available.

Throws

  • RuntimeError: If there is an error in during runtime.
  • JSONException: If there is an error in JSON parsing.