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 trioSession.refresh() with the keyId which returns Result of Success with Refreshed-Keyshare bytes as Data or Failure with error.

Example


Example.swift
    // refresh rotates the keyshares of the key addressed by keyId without changing
// its public key. The refreshed share is persisted under the same keyId.
func performKeyRefresh(keyId: String, trioSession: TrioSession) async -> Data? {
let result = await trioSession.refresh(keyId: keyId)
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let keyshareBytes):
// do something with the refreshed keyshare bytes
Swift.print(keyshareBytes)
return keyshareBytes
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}
  • keyId identifies the client's key to refresh; the SDK loads the keyshare from your StorageClient using it.
  • trioSession.refresh() performs message exchange between mobile and server to "refresh" the MPC wallet. Refer to Key Refresh for more details.
  • Result of trioSession.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.