hashAndSign static method

SignAndHash hashAndSign({
  1. required String message,
  2. required String privateKey,
})

Hashes the message and signs it with the private key. Returns the hash and signature.

Implementation

static SignAndHash hashAndSign({
  required String message,
  required String privateKey,
}) {
  final Uint8List hash = blakeHashToBinary(message);
  SigningKey signingKey = SigningKey.fromSeed(
    HEX.decode(privateKey).toUint8List(),
  );
  var sign = signingKey.sign(hash);
  return SignAndHash(
    hash: stripPadding(
      base64Url.encode(hash),
    ),
    sig: HEX.encode(sign.signature),
  );
}