sign method
Hashes the given data
with SHA-256, and then sign the hash using the
private key associated with this wallet, returning the signature
encoded as a 64 bytes array.
Implementation
Uint8List sign(Uint8List data) {
final hash = SHA256Digest().process(data);
final ecdsaSigner = ECDSASigner(null, HMac(SHA256Digest(), 64))
..init(true, PrivateKeyParameter(_ecPrivateKey));
final ecSignature = ecdsaSigner.generateSignature(hash) as ECSignature;
final normalized = _normalizeECSignature(ecSignature, ECCurve_secp256k1());
final rBytes = normalized.r.toUin8List();
final sBytes = normalized.s.toUin8List();
var sigBytes = Uint8List(64);
copy(rBytes, 32 - rBytes.length, 32, sigBytes);
copy(sBytes, 64 - sBytes.length, 64, sigBytes);
return sigBytes;
}