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.signature() which returns Result of Success with Signature bytes as Data or Failure with error.

Example


Example.swift
    let MESSAGE_HASH = "cfa1ff5424d14eb60614d7ddf65a32243d26ddf7000d10007853d7336395efe4"

func performSignature(keyshare: Data, duoSession: DuoSession) async -> Data?
{
let result = await duoSession.signature(
keyshare: keyshare, message: MESSAGE_HASH,
chainPath: "m" // This is the default, use your desired path here. For e.g 'm/1/2'
)
// returns nil if operation fails or other flow you might have
switch result {
case .success(let dataBytes):
do {
// do something with bytes
Swift.print(dataBytes)
return dataBytes
}
case .failure(let error):
do {
// show error to user or abort process
Swift.print(error)
return nil
}
}
}
  • keyshare is the client's "share" of the MPC wallet.
  • messageHash is the hash of the message to be signed as ByteArray.
  • 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.