getSignaturPublic static method

ECPublic? getSignaturPublic(
  1. String message,
  2. Uint8List signatur
)

get ECPublic of signatur

Implementation

static ECPublic? getSignaturPublic(String message, Uint8List signatur) {
  final msg = singleHash(magicMessage(message));
  int prefix = signatur[0];
  int recid = -1;
  if (prefix >= 31) {
    recid = prefix - 31;
  } else {
    recid = prefix - 27;
  }
  final rec =
      ec.recoverPublicKeyFromSignature(recid, signatur.sublist(1), msg);
  if (rec != null) {
    final ECPublic s = ECPublic.fromHex(bytesToHex(rec));
    return s;
  }
  return null;
}