sign method

String sign(
  1. String message, {
  2. bool forCompact = false,
})

Signs a message and optionally also calculates the first byte needed for compact format rendering.

NOTE: - subsequent

message - The message to sign

forCompact - If true then we perform additional calculation of first byte needed to render the signature in compact format with toCompact()

Implementation

String sign(String message, {bool forCompact = false}){

    if (_privateKey == null){
        throw SignatureException('Missing private key. Initialise this signature instance using fromPrivateKey()');
    }


    //sign it
    List<int> decodedMessage = Uint8List.fromList(HEX.decode(message).toList());

    _signature = _dsaSigner.generateSignature(decodedMessage as Uint8List) as ECSignature;
    _r = _signature!.r;
    _s = _signature!.s;
    _rHex = _r!.toRadixString(16);
    _sHex = _s!.toRadixString(16);

    _toLowS();

    //calculate _i_
    if (forCompact) {
        _calculateI(decodedMessage);
    }

    return toString();
}