Key Refresh
Please refer to the Session creation section to learn how to create a new session.
Full example:
- ECDSA
- EdDSA
main.dart
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;
Future<void> refresh(sdk.EcdsaSession session) async {
// Creating a new keyshare for demo purpose. In real application, you can use an existing keyshare.
final sdk.DklsKeyshare keyshare = await session.keygen();
print('Keyshare created, public key: ${keyshare.publicKeyHex}');
final sdk.DklsKeyshare refreshedKeyshare =
await session.refresh(keyId: keyshare.keyId);
print('Refreshed keyshare, public key: ${refreshedKeyshare.publicKeyHex}');
}
main.dart
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;
Future<void> refresh(sdk.EddsaSession session) async {
// Creating a new keyshare for demo purpose. In real application, you can use an existing keyshare.
final sdk.SchnorrKeyshare keyshare = await session.keygen();
print('Keyshare created, public key: ${keyshare.publicKeyHex}');
final sdk.SchnorrKeyshare refreshedKeyshare =
await session.refresh(keyId: await keyshare.keyId);
print('Refreshed keyshare, public key: ${refreshedKeyshare.publicKeyHex}');
}
- When
session.refresh(keyshare)is called, the app and the server exchange messages to "refresh" the MPC wallet. Refer to Key Refresh for more details. - 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.
- The
refreshedKeyshareobject is of type DklsKeyshare and represents the client's new share of the MPC wallet.
During refresh, there are risks involved of loosing the complete keyshare. So to provide fallback method we added reconcile protocol.
Learn more about working of reconcile protocol.