Skip to main content

Export Key


Users can at any time request to "export" their keys into a private key.

Step 1 : Create Session


Step 2 : Perform Export


  • Call trioSession.export() with the keyId which returns Result of Success with the exported private key bytes as Data or Failure with error.

Example


Example.swift
    // export reconstructs the raw private key for the key addressed by keyId (the
// SDK handles backup encryption internally, with no HTTP roundtrip). Treat the
// result like any private key — encrypt it at rest — and bring it back under
// MPC later with trioSession.import(keysharePrivateKey:).
func exportPrivateKey(keyId: String, trioSession: TrioSession) async -> Data? {
let result = await trioSession.export(keyId: keyId)
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let privateKeyBytes):
// do something with the reconstructed private-key bytes
Swift.print(privateKeyBytes)
return privateKeyBytes
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}

  • keyId: Identifies the client's (In this case mobile) key to export. The SDK loads the keyshare from your StorageClient and handles the backup encryption internally.