sign method

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

Signs the provided digest using the appropriate algorithm based on the available signing key.

digest The digest to be signed.

Implementation

List<int> sign(
  List<int> digest, {
  bool hashMessage = true,
  List<int>? extraEntropy,
}) {
  if (_signingKey != null) {
    return _signingKey.sign(digest, () => SHA512());
  } else {
    // If an ECDSA signing key is available, use the ECDSA algorithm for signing.
    final hash =
        hashMessage ? QuickCrypto.sha512HashHalves(digest).$1 : digest;
    return _ecdsaSigningKey!.signDer(
      digest: hash,
      extraEntropy: extraEntropy,
    );
  }
}