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 duoSession.keygen() which returns a Result of Success with the generated keyId (a String) or Failure with an error. The keyshare itself is persisted to your storage client, addressed by this keyId.

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(duoSession: DuoSession) async -> String? {
let result: Result<String, any Error> = await duoSession.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
}
}
  • duoSession.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 duoSession.keygen() could be a Success with a keyId (String) addressing the newly created keyshare in your storage client, or Failure with error
  • SilentShard.ECDSA.getKeysharePublicKey() or SilentShard.EdDSA.getKeysharePublicKey() could be used to get the compressed public key of the MPC wallet (read the keyshare bytes from your storage client by keyId first). Refer to SDK-Reference for additional Info and Utils.