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 duoSession.sign() with the keyId of the keyshare to sign with. It returns a Result of Success with the 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, duoSession: DuoSession) async -> Data? {
let result = await duoSession.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 addresses the client's keyshare in your storage client (returned by keygen/import).
  • messageHash is the hash of the message to be signed, passed as a hex String.
  • duoSession.sign() performs message exchange between mobile and server to generate a ECDSA/EdDSA signature.
  • Result of duoSession.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.