sign method

  1. @override
Encrypted sign(
  1. Uint8List bytes
)
override

Sign bytes.

Implementation

@override
Encrypted sign(Uint8List bytes) {
  if (privateKey == null) {
    throw StateError('Can\'t sign without a private key, null given.');
  }

  final hash = Uint8List(_digestCipher.digestSize);

  _digestCipher
    ..reset()
    ..update(bytes, 0, bytes.length)
    ..doFinal(hash, 0);

  _cipher
    ..reset()
    ..init(true, _privateKeyParams!);

  return Encrypted(_cipher.process(_encode(hash)));
}