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 the keyshare's public key (keysharePublicKey) to recover the share.
  • Call trioSession.recover() which returns Result of Success with a keyId (String) or Failure with exception.

Example


Example.kt
suspend fun performKeyRecovery(trioSession: TrioSession, storageClient: StorageClient): String {
return withContext(Dispatchers.IO) {

//At some point of time you might have done keygen.
val keyId = trioSession.keygen().getOrThrow()

//You might have stored public-key of the keyshare(ECDSA).
//Read the keyshare bytes from your StorageClient by keyId, then extract its public key.
val keyshare = (storageClient.read(keyId) as ReconcileStoreDao).currentKeyshare!!
val keysharePublicKey = SilentShard.ECDSA.getKeysharePublicKey(keyshare).getOrThrow()

// Perform recovery operation
val recoveredKeyId = trioSession.recover(keysharePublicKey = keysharePublicKey).getOrThrow()

recoveredKeyId
}
}
  • trioSession.recover() performs message exchange between mobile and server to "recover" the MPC wallet. Refer to Key Recovery for more details.
  • Result of trioSession.recover() could be a Success with a String (the recovered keyId) or Failure with Exception
  • 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.