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

Spatium SDK > signEcdsaMessage

signEcdsaMessage

suspend fun signEcdsaMessage(driver: ProtocolKotlin, secretId: String, syncSessionId: String, signSessionId: String, message: String): EcdsaSignature

Generate distributed ECDSA signature for a given message

This method requires an already performed synchronisation procedure and does not store anythig in the permanent storage. Messages of a length, different from 32 bytes are padded/truncated according to EDDSA algorithm.

Return

ECDSA signature in standard format

  • SeeAlso: ProtocolKotlin/signEcdsaMessage(secretId:syncSessionId:signSessionId:message:)

Example

// Assume an already performed synchronisation procedure and established connection

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

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

// Generate a ECDSA signature
val signature = signEcdsaMessage(secretId: String, syncSessionId: String, signSessionId: String, message: String)

// 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
     )
 )
)

Parameters

androidJvm

driver ProtocolKotlin implementation
secretId ID (UUID) of a secret used for synchronisation
syncSessionId ID (UUID) of a corresponding synchronisation procedure
signSessionId ID (UUID) of this signing procedure
message message (32 bytes, base64 encoded) to be signed