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 DuoSession if you haven't already.
Step 2 : Perform Sign
- Call
duoSession.signature()
which returnsResult
ofSuccess
withSignature
bytes asData
or Failure witherror
.
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 asByteArray
.duoSession.sign()
performs message exchange between mobile and server to generate a ECDSA/EdDSA signature.- Result of
duoSession.sign()
could be aSuccess
withData
(ECDSA/EdDSA signature) ofmessageHash
, corresponding to the public key (or address) of the wallet orFailure
witherror
.