sign method
Signs the provided digest using the appropriate algorithm based on the available signing key.
This method takes a digest as input and delegates the signing process to either the ED25519 or ECDSA algorithm based on the type of available signing key.
digest
The digest to be signed.
returns A list of bytes representing the generated signature using the appropriate algorithm.
The hashMessage
and extraEntropy
parameters are only applicable for ECDSA signing.
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).item1 : digest;
return _ecdsaSigningKey!
.signDer(digest: hash, extraEntropy: extraEntropy);
}
}