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

signEcdsaMessage

signEcdsaMessage(driver:secretId:syncSessionId:signSessionId:message:)

public func signEcdsaMessage(driver: ProtocolSwift, secretId: String, syncSessionId: String, signSessionId: String, message: String) async throws -> 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 ECDSA algorithm.

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

Example

 // Assume an already performed synchronisation procedure and established connection

 // Generate random session ID for a new signing session
 let signSessionId = UUID().uuidString

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

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

 // Verify the resulting signature against a compound public key
 print([
     "curve": EcdsaCurve.secp256k1,
     "publicKey": publicKey,
     "message": message,
     "signature": [
         "R": signature.R,
         "s": signature.s
     ] as [String : Any]
 ] as [String : Any])

Parameters

Name Description
driver ProtocolSwift 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

Returns

EcdsaSignature

ECDSA signature in standard format