verifyStringSignature function

Future<bool> verifyStringSignature(
  1. String jws, {
  2. String? expectedDid,
  3. Map<String, dynamic>? jwk,
  4. dynamic toSign,
  5. Erc1056? erc1056,
})

Verifies the signature in jws.

If a detached jws is given the signed string must be given separately as toSign. toSign could be a String or a json-object (Dart Map).

Implementation

Future<bool> verifyStringSignature(String jws,
    {String? expectedDid,
    Map<String, dynamic>? jwk,
    dynamic toSign,
    Erc1056? erc1056}) async {
  var signer = _determineSignerForJwsHeader(jws.split('.').first, null);
  if (expectedDid != null &&
      expectedDid.startsWith('did:ethr') &&
      erc1056 != null) {
    expectedDid = await erc1056.identityOwner(expectedDid);
  }

  return signer.verify(jws, did: expectedDid, jwk: jwk, data: toSign);
}