Skip to main content

Sign

This distributed signing process allows for secure transaction authorization while preserving the key's distributed nature, exemplifying the MPC wallet's enhanced security model.

Step 1 : Create Session


Step 2 : Perform Sign


  • Call trioSession.sign() which returns Result of Success with Signature bytes as Data or Failure with error.

Example


Example.swift
    let MESSAGE_HASH = "53c48e76b32d4fb862249a81f0fc95da2d3b16bf53771cc03fd512ef5d4e6ed9"

// Sign the message hash with the key addressed by keyId (from keygen/import).
func performSignature(keyId: String, trioSession: TrioSession) async -> Data? {
let result = await trioSession.sign(
keyId: keyId, message: MESSAGE_HASH,
derivationPath: "m" // This is the default; use your desired path, e.g. "m/1/2"
)
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let signatureBytes):
// do something with the signature bytes
Swift.print(signatureBytes)
return signatureBytes
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}
  • keyId identifies the client's key (from keygen/import); the SDK loads the keyshare from your StorageClient using it.
  • messageHash is the hash of the message to be signed as a hex String.
  • trioSession.sign() performs message exchange between mobile and server to generate a ECDSA/EdDSA signature.
  • Result of trioSession.sign() could be a Success with Data (ECDSA/EdDSA signature) of messageHash, corresponding to the public key (or address) of the wallet or Failure with error.