verify method
Implementation
@override
bool verify(proof, data, String did, {String? challenge}) {
//compare challenge
if (challenge != null) {
var containingChallenge = proof['challenge'];
if (containingChallenge == null) {
throw Exception('Expected challenge in this credential');
}
if (containingChallenge != challenge) {
throw Exception(
'challenge in credential do not match expected challenge');
}
}
var proofValue = proof.remove('proofValue');
List<int> hash = _dataToHash(data);
var proofHash = sha256.convert(utf8.encode(jsonEncode(proof))).bytes;
var hashToSign = sha256.convert(proofHash + hash).bytes;
proof['proofValue'] = proofValue;
var encodedKey = did.split(':')[2];
var base58DecodedKey = base58BitcoinDecode(encodedKey.substring(1));
return ed.verify(
ed.PublicKey(base58DecodedKey.sublist(2)),
Uint8List.fromList(hashToSign),
base58BitcoinDecode(proofValue.substring(1)));
}