sign method

List<int> sign(
  1. List<int> digest, {
  2. bool hashMessage = true,
  3. List<int>? extraEntropy,
})

Signs a message digest using the ECDSA algorithm on the secp256k1 curve.

Parameters:

  • digest: The message digest to be signed.
  • hashMessage: Whether to hash the message before signing (default is true).

Throws:

Implementation

List<int> sign(
  List<int> digest, {
  bool hashMessage = true,
  List<int>? extraEntropy,
}) {
  final hash = hashMessage ? QuickCrypto.sha256Hash(digest) : digest;
  final signature = _ecdsaSigningKey.sign(
    digest: hash,
    extraEntropy: extraEntropy,
  );
  return [
    ...signature.$1.toBytes(CryptoSignerConst.digestLength),
    signature.$2 + 27,
  ];
}