Skip to main content

Share Serialization Module

The ShareSerializationModule is an Android module that provides functionality for serializing and deserializing threshold key shares.

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

ShareSerializationModule is a class that provides the following methods:

FunctionDescriptionArgumentsAsyncreturn
serializeShareSerialize sharethresholdKey: ThresholdKey, share: String, format: String?NoString
deserializeShareDeserialize sharethresholdKey: ThresholdKey, share: String, format: String?NoString

serializeShare()

public static String serializeShare(ThresholdKey thresholdKey, String share, @Nullable String format) throws RuntimeError

This method serializes a threshold key share and returns it as a string.

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA ThresholdKey object that represents the threshold key to which the share belongs.
shareStringA string that represents the share to be serialized.
formatString?An optional string that represents the serialization format. If it is not specified, the default format will be used.

Returns

  • A string that represents the serialized share.

Throws

  • RuntimeError: If the serialization operation fails, a RuntimeError will be thrown.

deserializeShare()

deserializeShare(thresholdKey: ThresholdKey, share: String, format: String?) throws -> String

This method deserializes a threshold key share and returns it as a string.

Parameters

ParametersTypeDescription
thresholdKeyThresholdKeyA ThresholdKey object that represents the threshold key to which the share belongs.
shareStringA string that represents the share to be deserialized.
formatString?An optional string that represents the serialization format. If it is not specified, the default format will be used.

Returns

  • A string that represents the deserialized share.

Throws

  • RuntimeError: If the deserialization operation fails, a RuntimeError will be thrown.