Key Refresh
Update the client's and server's secret shares without altering the wallet's public address or key.
Step 1 : Create Session
- Create DuoSession if you haven't already.
Step 2 : Perform Key-Refresh
- Call duoSession.refresh() with the
keyIdof the keyshare to refresh. It returns aResultofSuccesswithDataorFailurewitherror. The refreshed keyshare is persisted to your storage client under the samekeyId.
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
}
}
keyIdaddresses the client's keyshare in your storage client (returned bykeygen/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
Successwith bytes asData(client's new share of the MPC wallet) orFailurewitherror - 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.