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 Result of Success with Signature ByteArray or Failure with exception.
Example
Example.kt
val messageHash = "e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03"
// Sign the message hash with the key addressed by keyId (returned from keygen/import).
suspend fun performSignature(keyId: String, trioSession: TrioSession): ByteArray {
return withContext(Dispatchers.IO) {
trioSession.sign(
keyId = keyId,
message = messageHash,
derivationPath = "m" // This is the default; use your desired path, e.g. "m/1/2"
).getOrThrow()
}
}
keyIdis the identifier returned by keygen that addresses the client's keyshare in your storage.messageHashis the hash of the message to be signed asByteArray.- trioSession.sign() performs message exchange between mobile and server to generate a ECDSA/EdDSA signature.
- Result of trioSession.sign() could be a
SuccesswithByteArray(ECDSA/EdDSA signature) ofmessageHash, corresponding to the public key (or address) of the wallet orFailurewithException.