Skip to main content

Key Refresh

Update the client's and server's secret shares without altering the wallet's public address or key.

Step 1 : Create Session


Step 2 : Perform Key-Refresh


  • Call duoSession.refresh() with the keyId of the keyshare to refresh. It returns a Result of Success with Data or Failure with error. The refreshed keyshare is persisted to your storage client under the same keyId.

Example


Example.swift
    // Rotate the keyshares of the key addressed by keyId (from keygen/import).
// The public key stays the same; the refreshed share is persisted under the
// same keyId in your StorageClient.
func performRefresh(keyId: String, duoSession: DuoSession) async -> Data? {
let result = await duoSession.refresh(keyId: keyId)
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let refreshedKeyshare):
// do something with the refreshed keyshare bytes
Swift.print(refreshedKeyshare)
return refreshedKeyshare
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}
  • keyId addresses the client's keyshare in your storage client (returned by keygen/import).
  • duoSession.refresh() performs message exchange between mobile and server to "refresh" the MPC wallet. Refer to Key Refresh for more details.
  • Result of duoSession.refresh() could be a Success with bytes as Data (client's new 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.