Table of Contents

Class Sr25519

Namespace
SodotSDK.Sr25519
Assembly
Unity.Temp.dll

Class providing the functionality for the Sr25519 protocol the implementing FROST MPC protocol.

public class Sr25519 : Scheme
Inheritance
MonoBehaviour
Sr25519
Inherited Members

Constructors

Sr25519(string)

Initializes a new instance of the Sr25519 class.

public Sr25519(string hostUrl)

Parameters

hostUrl string

The host URL for the Relay server.

Methods

DerivePrivateKeyFromPrivateKey(string, string[], bool)

Derives a private key from another private key using a derivation path.

public Task<Sr25519PublicKey> DerivePrivateKeyFromPrivateKey(string xpub, string[] derivationPath, bool isPrivateKeyRaw)

Parameters

xpub string

The private key (xpub) as a hex string.

derivationPath string[]

The derivation path for the key.

isPrivateKeyRaw bool

Indicates if the private key is in raw format.

Returns

Task<Sr25519PublicKey>

The derived public key.

DerivePubkey(Sr25519SecretShare, string[])

Derives a public key from a Sr25519SecretShare using the specified derivation path.

public Task<Sr25519PublicKey> DerivePubkey(Sr25519SecretShare secretShare, string[] derivationPath)

Parameters

secretShare Sr25519SecretShare

The secret share.

derivationPath string[]

The derivation path for the key.

Returns

Task<Sr25519PublicKey>

The derived public key.

DerivePubkeyFromPubkey(string, string[])

Returns returns a hex encoded extended public key from a Sr25519SecretShare.

public Task<PrivateKey> DerivePubkeyFromPubkey(string pubkey, string[] derivationPath)

Parameters

pubkey string

The public key as a hex string.

derivationPath string[]

The derivation path for the key.

Returns

Task<PrivateKey>

The derived private key.

ExportFullPrivateKey(Uuid, Sr25519SecretShare, KeygenId)

Exports the full private key to a single party by combining all of the secret shares.

public Task<string> ExportFullPrivateKey(Uuid uuid, Sr25519SecretShare secretShare, KeygenId keygenId)

Parameters

uuid Uuid

The room UUID.

secretShare Sr25519SecretShare

The secret share.

keygenId KeygenId

The export target keygen ID.

Returns

Task<string>

The exported private key as a hex string.

GetExportId(Sr25519SecretShare)

Gets the export ID from a secret share. The party that expects to receive the private key needs to call this function before ExportFullPrivateKey(Uuid, Sr25519SecretShare, KeygenId). It must then transmit the ID to threshold-1 parties, this can be done in an untrusted channel (as if the parties use different keys this will break) Once the parties have the exportID of the party they want to export the private key to, the party and the threshold-1 participants need to call exportFullPrivatekey with that ID.

public Task<KeygenId> GetExportId(Sr25519SecretShare secretShare)

Parameters

secretShare Sr25519SecretShare

The secret share.

Returns

Task<KeygenId>

The export ID as a KeygenId.

GetPubkey(Sr25519SecretShare)

Returns returns a hex encoded extended public key from a Sr25519SecretShare.

public Task<Sr25519PublicKey> GetPubkey(Sr25519SecretShare secretShare)

Parameters

secretShare Sr25519SecretShare

The secret share.

Returns

Task<Sr25519PublicKey>

The public key as an Sr25519PublicKey.

ImportPrivateKeyImporter(Uuid, ushort, string, KeygenSecret, KeygenId[], bool)

Imports a private key for an importer in a threshold scheme. WARNING: Private key import is an advanced feature of the SDK. We strongly advise consulting with the Sodot team before using it, due to a full private key being imported from a different system. Secret shares generated from imported private keys will always have the risk of the private key having been compromised in the past or in the future in case the private key is not deleted after the import operation. Importing a full private key, and sharing into a T-of-N sharing, the resultant key shares will be of the exact same public key as the full private key. This is the method that an importing party (meaning one the party in possesion of the private key) should use for receiving a key share in the new T-of-N quorum.

public Task<(Sr25519PublicKey, Sr25519SecretShare)> ImportPrivateKeyImporter(Uuid uuid, ushort threshold, string privateKeyHex, KeygenSecret keygenSecret, KeygenId[] keygenIds, bool isPrivateKeyRaw)

Parameters

uuid Uuid

The room UUID.

threshold ushort

The threshold for the key share.

privateKeyHex string

The private key as a hex string.

keygenSecret KeygenSecret

A KeygenSecret returned from InitKeygen.

keygenIds KeygenId[]

The keygen IDs of the parties.

isPrivateKeyRaw bool

Indicates if the private key is in raw format.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The public key and secret share.

ImportPrivateKeyRecipient(Uuid, ushort, KeygenSecret, KeygenId[])

Imports a private key for a recipient in a threshold scheme. WARNING: Private key import is an advanced feature of the SDK. We strongly advise consulting with the Sodot team before using it, due to a full private key being imported from a different system. Secret shares generated from imported private keys will always have the risk of the private key having been compromised in the past or in the future in case the private key is not deleted after the import operation. Importing a full private key, and sharing into a T-of-N sharing, the resultant key shares will be of the exact same public key as the full private key. This is the method that a new party (meaning one that does not currently have the private key) should use for receiving a key share in the new T-of-N quorum. The method takes the same input parameters as keygen since for a new party joining the quorum the import operation is very similar to a keygen operation.

public Task<(Sr25519PublicKey, Sr25519SecretShare)> ImportPrivateKeyRecipient(Uuid uuid, ushort threshold, KeygenSecret keygenSecret, KeygenId[] keygenIds)

Parameters

uuid Uuid

The room UUID.

threshold ushort

The threshold for the key share.

keygenSecret KeygenSecret
keygenIds KeygenId[]

The keygen IDs of the parties.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The public key and secret share.

Keygen(Uuid, ushort, ushort, KeygenSecret, KeygenId[])

Starts a distributed key generation for Sr25519.

public Task<(Sr25519PublicKey, Sr25519SecretShare)> Keygen(Uuid uuid, ushort numParties, ushort threshold, KeygenSecret keygenSecret, KeygenId[] keygenIds)

Parameters

uuid Uuid

The room UUID.

numParties ushort

Number of parties.

threshold ushort

Threshold value.

keygenSecret KeygenSecret

A KeygenSecret returned from InitKeygen.

keygenIds KeygenId[]

Array of keygen IDs.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The public key and secret share.

OfflineExportFullPrivateKey(Sr25519SecretShare[])

Exports the full private key offline for a set of secret shares. Requires a threshold amount of parties to participate.

public Task<string> OfflineExportFullPrivateKey(Sr25519SecretShare[] secretShares)

Parameters

secretShares Sr25519SecretShare[]

The secret shares to export.

Returns

Task<string>

The exported private key as a hex string.

Refresh(Uuid, Sr25519SecretShare)

Refreshes the key pair by generating a new public key and secret share. Takes an Sr25519SecretShare as input and returns a new one for the same public key but with fresh key material. Be careful to delete the Sr25519SecretShare given as input before it is certain that all devices have properly stored the fresh Sr25519SecretShare that is output. Note that the new Sr25519SecretShare-s may only be used with each other, attempting to use older Sr25519SecretShare-s with newer ones for signing will result in failure.

public Task<(Sr25519PublicKey, Sr25519SecretShare)> Refresh(Uuid uuid, Sr25519SecretShare secretShare)

Parameters

uuid Uuid

The room UUID.

secretShare Sr25519SecretShare

The secret share to refresh.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The new public key and secret share.

ReshareNewParty(Uuid, ushort, KeygenSecret, KeygenId[])

Reshares the secret share to a new party with a new threshold. WARNING: Key resharing is an advanced feature of the SDK. We strongly advise consulting with the Sodot team before using it, as incorrect usage might lead to the detriment of the private key security. To use the feature correctly, developers using this feature must make sure that at least n - t + 1 parties of the t-of-n signing quorum delete their current shares before using the resharing of the private key. Also, after resharing, the resharing operation must not be considered complete until such deletion has occurred. Since deleting a share cannot be guaranteed cryptographically, it must be guaranteed by the software architecture (hence, by the developers using the SDK).

public Task<(Sr25519PublicKey, Sr25519SecretShare)> ReshareNewParty(Uuid uuid, ushort newThreshold, KeygenSecret keygenSecret, KeygenId[] keygenIds)

Parameters

uuid Uuid

The room UUID.

newThreshold ushort

The new threshold value.

keygenSecret KeygenSecret

A KeygenSecret returned from InitKeygen.

keygenIds KeygenId[]

The keygen IDs of the parties.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The public key and secret share for the new party.

ReshareRemainingParty(Uuid, ushort, Sr25519SecretShare, KeygenId[])

Reshares the remaining party's secret share to a new threshold. WARNING: Key resharing is an advanced feature of the SDK. We strongly advise consulting with the Sodot team before using it, as incorrect usage might lead to the detriment of the private key security. To use the feature correctly, developers using this feature must make sure that at least n - t + 1 parties of the t-of-n signing quorum delete their current shares before using the resharing of the private key. Also, after resharing, the resharing operation must not be considered complete until such deletion has occurred. Since deleting a share cannot be guaranteed cryptographically, it must be guaranteed by the software architecture (hence, by the developers using the SDK).

public Task<(Sr25519PublicKey, Sr25519SecretShare)> ReshareRemainingParty(Uuid uuid, ushort newThreshold, Sr25519SecretShare secretShare, KeygenId[] keygenIds)

Parameters

uuid Uuid

The room UUID.

newThreshold ushort

The new threshold value.

secretShare Sr25519SecretShare

The secret share of the party.

keygenIds KeygenId[]

The keygen IDs of the parties.

Returns

Task<(Sr25519PublicKey, Sr25519SecretShare)>

The public key and secret share for the reshared party.

Sign(Uuid, Sr25519SecretShare, byte[], string[])

Signs a message with the Sr25519SecretShare.Notice that unlike ECDSA, in Sr25519 there's no need to hash the message before signing it.

public Task<Sr25519Signature> Sign(Uuid uuid, Sr25519SecretShare secretShare, byte[] msg, string[] derivationPath)

Parameters

uuid Uuid

The room UUID.

secretShare Sr25519SecretShare

The secret share.

msg byte[]

The message sign.

derivationPath string[]

The derivation path for the key.

Returns

Task<Sr25519Signature>

The signature.