Перейти к содержанию

[Spatium SDK]((index.md) > syncDistributedEcdsaKey

syncDistributedEcdsaKey

suspend fun syncDistributedEcdsaKey(driver: ProtocolKotlin, secretId: String, syncSessionId: String, curve: EcdsaCurve, derivationCoin: UInt, derivationAccount: UInt): String

Perform distributed key synchronisation procedure

Each secret is independently used to generate distributed key fragments (BIP-44 with path m/44'/(coin)'/(account)'/0'/0'), and then MPC key synchronisation is performed over these fragments in order to get a compound public key for that pair.

Despite each session is bearing a unique set of data, the resulting key is deterministic in regards to further synchronisations, e.g. each set of secrets, coin and account always result in the same compound public key (and ephemeral private keys).

As a result of this operation, a new synchronisation session data is saved to a persistent storage, accessible by the provided session ID. From this point one may freely call getEcdsaPublicKey(driver:secretId:syncSessionId:) or signEcdsaMessage(driver:secretId:syncSessionId:signSessionId:message:) as long as synchronisation data (and secret) is accessible in the storage.

Return

compound public key (which may also be accessed via getEcdsaPublicKey(driver:secretId:syncSessionId:) later)

  • SeeAlso: ProtocolKotlin/syncDistributedEcdsaKey(secretId:syncSessionId:curve:derivationCoin:derivationAccount:)

Example

// Assume an already generated secret and established connection

// Generate random session ID for a new synchronisation session
val syncSessionId = UUID.randomUUID().toString()

// Perform a ECDSA-over-secp256k1 synchronisation procedure for a key with path `m/44'/0'/0'/0'/0'
val publicKey = syncDistributedEcdsaKey(secretId: String, syncSessionId: String, curve: EcdsaCurve, derivationCoin: UInt32, derivationAccount: UInt32)

// At this point synchronisation data is saved to the storage so one may access it to get a compound public key
val _publicKey = getEcdsaPublicKey(secretId: String, syncSessionId: String)

// Which is obviously the same key that was returned from the synchronisation procedure itself
Assert.assertEquals(publicKey, _publicKey)

Parameters

androidJvm

driver ProtocolKotlin implementation
secretId ID (UUID) of a secret to be used for synchronisation
syncSessionId ID (UUID) of this synchronisation procedure
curve elliptic curve to use (only .secp256k1 is supported at the moment)
derivationCoin "coin" property of HD key derivation (BIP-44)
derivationAccount "account" property of HD key derivation (BIP-44)