Skip to main content

Keygen

This distributed key generation forms the basis for all subsequent MPC operations, providing a secure foundation for the wallet with enhanced privacy and security guarantees.

Step 1 : Create Session


Step 2 : Perform Keygen


  • Call trioSession.keygen() which returns Result of Success with the generated key's keyId as a String or Failure with an error.

Example


Example.swift
    // keygen returns the new keyId (a String). The keyshare is persisted to your
// StorageClient — keep the keyId to address it in later operations.
func performKeygen(trioSession: TrioSession) async -> String? {
let result: Result<String, any Error> = await trioSession.keygen()
// returns nil if the operation fails, or handle it however your flow needs
switch result {
case .success(let keyId):
// do something with the keyId
Swift.print(keyId)
return keyId
case .failure(let error):
// show the error to the user or abort the process
Swift.print(error)
return nil
}
}
  • trioSession.keygen() performs message exchange between mobile and server to generate a new MPC wallet.
  • Two new "shares" are generated: one for the client(on mobile) and one for the server(on server). Both shares together form the MPC wallet.
  • Result of trioSession.keygen() could be a Success with a keyId (String) that identifies the generated key or Failure with error. The client's keyshare is persisted through your StorageClient, addressed by this keyId.
  • SilentShard.ECDSA.getKeysharePublicKey() or SilentShard.EdDSA.getKeysharePublicKey() could be used to get the compressed public key of the MPC wallet. Refer to SDK-Reference for additional Info and Utils.