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

Spatium SDK > ProtocolKotlin

ProtocolKotlin

interface ProtocolKotlin

Secure MPC signature protocol for ECDSA and EDDSA systems

Builds upon Crypto and Transport Drivers, thus completely encapsulating data cryptography and message transmission within the MPC algorithms. For now, only 2-out-of-2 signature scheme is supported internally, however the interface should still remain the same for more schemes with more parties.

// Assuming an already existing secret boud to secretId

// 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(driver, secretId, syncSessionId, EcdsaCurve.secp256k1 , 0, 0);

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

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

// Generate random session ID for a new signing session
const signSessionId = UUID.randomUUID().toString()

// Message to be signed
val message = "7hJ9yN2OdIQo2kJu0arZgw2EKnMX5FGtQ6jlCWuLXCM="

// Generate a ECDSA signature
val signature = signEcdsaMessage(driver, secretId, syncSessionId, signSessionId, message, signatureToken)

// Verify the resulting signature against a compound public key
println(
 mapOf(
     "curve" to EcdsaCurve.secp256k1,
     "publicKey" to publicKey,
     "message" to message,
     "signature" to mapOf(
         "r" to signature.r,
         "s" to signature.s,
         "recovery" to signature.recovery
     )
 )
)

Inheritors

SpatiumProtocol

Functions

Name Summary
getEcdsaPublicKey [androidJvm]
abstract suspend fun getEcdsaPublicKey(secretId: String, syncSessionId: String): String
Get a compound public key from an already performed synchronisation session
getEddsaPublicKey [androidJvm]
abstract suspend fun getEddsaPublicKey(secretId: String, syncSessionId: String): String
Get a compound public key from an already performed synchronisation session
off [androidJvm]
abstract fun off()
Unsubscribe from server-side events
on [androidJvm]
abstract fun on(validateMessage: (message: String, signatureToken: String) -> Boolean)
Subscribe to server-side events
removeDistributedEcdsaKey [androidJvm]
abstract suspend fun removeDistributedEcdsaKey(secretId: String, syncSessionId: String)
Remove an already performed synchronisation session from storage
removeDistributedEddsaKey [androidJvm]
abstract suspend fun removeDistributedEddsaKey(secretId: String, syncSessionId: String)
Remove an already performed synchronisation session from storage
signEcdsaMessage [androidJvm]
abstract suspend fun signEcdsaMessage(secretId: String, syncSessionId: String, signSessionId: String, message: String, signatureToken: String): EcdsaSignature
Generate distributed ECDSA signature for a given message
signEddsaMessage [androidJvm]
abstract suspend fun signEddsaMessage(secretId: String, syncSessionId: String, signSessionId: String, message: String, signatureToken: String): EddsaSignature
Generate distributed EDDSA signature for a given message
syncDistributedEcdsaKey [androidJvm]
abstract suspend fun syncDistributedEcdsaKey(secretId: String, syncSessionId: String, curve: EcdsaCurve, derivationCoin: UInt, derivationAccount: UInt): String
Perform distributed key synchronisation procedure
syncDistributedEddsaKey [androidJvm]
abstract suspend fun syncDistributedEddsaKey(secretId: String, syncSessionId: String, curve: EddsaCurve, derivationCoin: UInt, derivationAccount: UInt): String
Perform distributed key synchronisation procedure