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
- Create DuoSession if you haven't already.
Step 2 : Perform Keygen
- Call
duoSession.keygen()
which returns Result ofSuccess
with Keyshare bytes asData
object orFailure
with an error.
Example
Example.swift
func performKeygen(duoSession: DuoSession) async -> Data? {
let result: Result<Data, any Error> = await duoSession.keygen()
// returns nil if operation fails or other flow you might have
switch result {
case .success(let dataBytes):
do {
// do something with bytes
Swift.print(dataBytes)
return dataBytes
}
case .failure(let error):
do {
// show error to user or abort 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 aSuccess
withData
(client's keyshare) orFailure
witherror
SilentShardDuo.ECDSA.getKeysharePublicKeyAsHex
orSilentShardDuo.EdDSA.getKeysharePublicKeyAsHex
could be used to get the compressed public key of the MPC wallet. Refer to SDK-Reference for additional Info and Utils.