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
- Create TrioSession if you haven't already.
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
- ECDSA
- EdDSA
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
}
}
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(EdDSA).
//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.EdDSA.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
Successwith aString(the recoveredkeyId) orFailurewithException - 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.