Skip to main content

Key Recovery

Restore the client's secret shares to regain access to the wallet without changing its public address or key.

Step 1 : Create Session


Step 2 : Perform Key-Refresh


  • We need to have key-share's public key to recover the share.
  • Call trioSession.recovery() which returns Result of Success with Refreshed-Keyshare bytes as Data or Failure with error.

Example


Example.swift
func performKeyRecovery(trioSession: TrioSession) async -> Data?
{
//At some point of time you might have done keygen.
let keyshare = await performKeygen(trioSession : trioSession)

//You might have stored public-key of the keyshare(ECDSA).
let keysharePublicKey = await getKeysharePublicKey(keyshare: keyshare!)

let result = await trioSession.recovery(
keysharePublicKey: keysharePublicKey!
)
// 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
}
}
}

//At some point of time you might have done keygen.
func performKeygen(trioSession: TrioSession) async -> Data? {
let result: Result<Data, any Error> = await trioSession.keygen()
// 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
}
}
}

//You might have stored public-key of the keyshare(ECDSA).
func getKeysharePublicKey(keyshare : Data) async -> Data? {
let result: Result<Data, any Error> = await SilentShard.ECDSA.getKeysharePublicKey(
keyshare
)
// 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
}
}
}
  • trioSession.recovery() performs message exchange between mobile and server to "recover" the MPC wallet. Refer to Key Recovery for more details.
  • Result of trioSession.recovery() could be a Success with bytes as Data (client's recovered share of the MPC wallet) or Failure with error
  • This process enhances the long-term security of the MPC wallet by proactively updating the client's and server's secret shares.
  • The wallet's public address or key remains unchanged during this process.