verifySuiSignature function
BLAKE2b-256 of the intent message (or the given hash) + Ed25519 verification.
Implementation
VerifyResult verifySuiSignature(VerifySuiSignatureArgs args) {
Uint8List digest;
final messageHash = args.messageHash;
final intentMessage = args.intentMessage;
if (messageHash != null) {
if (messageHash.length != 32) return failed('messageHash must be 32 bytes');
digest = messageHash;
} else if (intentMessage != null) {
digest = suiIntentDigest(intentMessage);
} else {
return failed('provide intentMessage or messageHash');
}
final expectedPublicKey = args.expectedPublicKey;
if (expectedPublicKey != null &&
!equalBytes(args.publicKey, expectedPublicKey)) {
return failed('the reply public key is not the linked account key');
}
bool ok;
try {
ok = ed25519Verify(args.publicKey, digest, args.signature);
} on Object catch (e) {
return failed('Sui signature could not be checked: $e');
}
return ok
? verified
: failed('the signature does not belong to this account');
}