refresh
Refreshes an existing keyshare without changing its public key.
Proactive security measure to protect against potential key leakage. Recommended every 30-90 days. Public key and addresses remain unchanged.
Important: KeyRefresh internally performs reconciliation automatically. Manual reconciliation with reconcile is only needed in case of failure (e.g., crash or network interruption).
Example: MPC Keyshare Refresh and Recovery
suspend fun refreshKeyshareIfNeeded(
session: DuoSession,
storage: StorageClient<ReconcileStoreDao>,
keyId: String
) {
val dao = storage.read(keyId)
val currentKeyshare = dao?.currentKeyshare
// MPC: Only refresh if currentKeyshare exists and is old enough
if (currentKeyshare != null && isKeyshareOld(keyId)) {
println("Refreshing MPC keyshare for $keyId...")
val refreshedKeyshare = session.refresh(currentKeyshare).getOrThrow()
// Use refreshedKeyshare immediately
println("Refreshed keyshare for $keyId")
}
// MPC: In case of failure, check for staged keyshare and retry reconciliation
if (dao?.stagedKeyshare != null && dao.currentKeyshare == null) {
println("Recovery: Retrying reconciliation for $keyId...")
val reconciledKeyshare = session.reconcile(keyId).getOrThrow()
println("Reconciliation complete for $keyId")
}
}Content copied to clipboard
Return
Result containing the refreshed keyshare bytes (same public key, fresh share). The updated keyshare is also persisted under the same keyId in storage.
Parameters
keyId
Hex-encoded keyId of the keyshare to refresh. The SDK looks up the current keyshare via the owned StorageClient.
See also
only for retry in case of failure