recoverPublicKeyFromSignature static method

Uint8List? recoverPublicKeyFromSignature(
  1. ECDSASignature sig,
  2. Uint8List message, {
  3. int? chainId,
})

Implementation

static Uint8List? recoverPublicKeyFromSignature(
    ECDSASignature sig, Uint8List message,
    {int? chainId}) {
  int recoveryId = _calculateSigRecovery(sig.v, chainId: chainId);
  if (!_isValidSigRecovery(recoveryId)) {
    throw ArgumentError("invalid signature v value");
  }

  if (!isValidSignature(sig.r, sig.s, sig.v, chainId: chainId)) {
    throw ArgumentError("invalid signature");
  }

  return _recoverPublicKeyFromSignature(recoveryId, sig.r, sig.s, message);
}