privateSign static method

String privateSign(
  1. String strPrivateKey,
  2. String message
)

Implementation

static String privateSign(String strPrivateKey, String message) {
  ECPrivateKey privateKey = loadPrivateKey(strPrivateKey);
  ECDSASigner singer = ECDSASigner(SHA512Digest(), Mac('SHA-512/HMAC'));
  var privParams =
      PrivateKeyParameter(ECPrivateKey(privateKey.d, privateKey.parameters));
  var signParams = () => ParametersWithRandom(privParams, NullSecureRandom());
  singer.init(true, signParams());
  ECSignature signature = singer.generateSignature(
      Uint8List.fromList(convert.utf8.encode(message))) as ECSignature;
  final xs = signature.r.toRadixString(16);
  final ys = signature.s.toRadixString(16);
  final hexX = leftPadding(xs, 64);
  final hexY = leftPadding(ys, 64);
  return hexX + hexY;
}