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
- Create TrioSession if you haven't already.
Step 2 : Perform Sign
- Call trioSession.sign() which returns
ResultofSuccesswithSignaturebytes asDataor Failure witherror.
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
}
}
keyIdidentifies the client's key (fromkeygen/import); the SDK loads the keyshare from your StorageClient using it.messageHashis the hash of the message to be signed as a hexString.- trioSession.sign() performs message exchange between mobile and server to generate a ECDSA/EdDSA signature.
- Result of trioSession.sign() could be a
SuccesswithData(ECDSA/EdDSA signature) ofmessageHash, corresponding to the public key (or address) of the wallet orFailurewitherror.