signBytes method
Sign the given bytes, and wrap in signature. The message is prepended with "MX" for domain separation.
Implementation
Future<crypto.Signature> signBytes(Uint8List bytes) async {
// Prepend the bytes
final signPrefix = utf8.encode(BYTES_SIGN_PREFIX);
// Merge the byte arrays
final buffer = Uint8List.fromList([
...signPrefix,
...bytes,
]);
// Sign the transaction with secret key
final signature = await Ed25519().sign(
buffer,
keyPair: keyPair,
);
return crypto.Signature(bytes: Uint8List.fromList(signature.bytes));
}