checkValid method
Implementation
bool checkValid() {
VerifyKey key = publicKey;
if (hasSeed) {
// check 'seed' & 'fingerprint'
} else if (containsKey('seed') || containsKey('fingerprint')) {
// this meta has no seed, so
// it should not contains 'seed' or 'fingerprint'
return false;
} else {
// this meta has no seed, so it's always valid
// when the public key exists
return true;
}
String? name = seed;
Uint8List? signature = fingerprint?.bytes;
// check meta seed & signature
if (signature == null || signature.isEmpty ||
name == null || name.isEmpty) {
assert(false, 'meta error: ${super.toMap()}');
return false;
}
// verify fingerprint
Uint8List data = UTF8.encode(name);
return key.verify(data, signature);
}