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.

Optionally, the message can be hashed before signing.

Parameters:

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

Returns:

  • A byte list representing the signature of the message digest.

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.item1.toBytes(CryptoSignerConst.digestLength),
    signature.item2 + 27
  ];
}