Sign
Please refer to the Session creation section to learn how to create a new session.
Full example
- ECDSA
- EdDSA
main.dart
import 'dart:typed_data';
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;
// This could be a hash digest of any message you want to sign.
// For example, for the Ethereum transaction signing, you would use the keccak256 hash of the transaction data.
const messageHash =
'e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03';
Future<Uint8List> signGen(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 signature = await session.sign(
keyId: keyshare.keyId,
messageHash: messageHash,
);
print('Signature: $signature');
return signature;
}
main.dart
import 'package:silent_shard_sdk/silent_shard_sdk.dart' as sdk;
// This could be a hash digest of any message you want to sign.
// For example, for the Ethereum transaction signing, you would use the keccak256 hash of the transaction data.
const messageHash =
'e2a159d17b7bb714aed7675d7c7d394dec8d2e4337842848104694bf89c71c03';
Future<void> signGen(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 signature = await session.sign(
keyId: await keyshare.keyId,
messageHash: messageHash,
);
print('Signature: $signature');
}
- DklsKeyshare is the client's "share" of the MPC wallet.
messageHashis the hash of the message to be signed as a hex string.- When
session.sign()is called, the app and the server exchange messages to generate an ECDSA signature. signatureis the signature (hex string) ofmessageHash, corresponding to the public key (or address) of the wallet.