verifyDerWithHashType static method

bool verifyDerWithHashType(
  1. String message,
  2. Uint8List publicKey,
  3. String signature
)

Verify a DER-encoded signature with a trailing sighash byte — the format DOGE/LTC(non-Taproot)/BCH sign() actually produce. Returns false for malformed DER instead of throwing.

Implementation

static bool verifyDerWithHashType(
    String message, Uint8List publicKey, String signature) {
  try {
    final encoded = dynamicToUint8List(signature);
    if (encoded.length < 9 || 2 + encoded[1] + 1 != encoded.length) {
      return false;
    }
    final raw = derToRaw(encoded);
    return verify(message, publicKey, dynamicToString(raw));
  } catch (_) {
    return false;
  }
}