verify method
Verifies the TAI signature against the entity's public key.
metaKey is the public key from the entity's Meta data (meta.key).
Returns true if signature is valid (data hasn't been tampered with), false otherwise.
Implementation
@override
bool verify(VerifyKey publicKey) {
// if (_status > 0) {
// // already verify OK
// return true;
// }
String? data = _getData();
Uint8List? signature = _getSignature();
if (data == null || data.isEmpty) {
// NOTICE: if data is empty, signature should be empty at the same time
// this happen while entity document not found
if (signature == null || signature.isEmpty) {
_status = 0;
} else {
// data signature error
_status = -1;
}
} else if (signature == null || signature.isEmpty) {
// data signature error
_status = -1;
} else if (publicKey.verify(UTF8.encode(data), signature)) {
// signature matched
_status = 1;
} else {
// public key not matched,
// no need to affect the status here
return false;
}
// NOTICE: if status is 0, it doesn't mean the entity document is invalid,
// try another key
return _status == 1;
}