sign method

Uint8List sign(
  1. Uint8List data
)

Signs the given data using the private key associated with this wallet, returning the signature bytes ASN.1 DER encoded.

Implementation

Uint8List sign(Uint8List data) {
  final ecdsaSigner = Signer('SHA-256/ECDSA')
    ..init(
        true,
        ParametersWithRandom(
          PrivateKeyParameter(_ecPrivateKey),
          _getSecureRandom(),
        ));
  final ecSignature =
      _toCanonicalised(ecdsaSigner.generateSignature(data) as ECSignature);

  const bigIntEndian = BigIntBigEndian();
  final sigBytes = Uint8List.fromList(bigIntEndian.encode(ecSignature.r) +
      bigIntEndian.encode(ecSignature.s));

  return sigBytes;
}