verify method
Verifies a signature for the provided message using this COSE public key.
Throws an Exception if verification fails or the algorithm is unsupported.
Implementation
@override
Future<void> verify(List<int> message, List<int> signature) async {
final xBytes = this[CoseKey.okpXIdx] as List<int>?;
if (xBytes == null) {
throw Exception('Ed25519 verification failed: missing public key (x).');
}
// Ed25519 signatures must be exactly 64 bytes (R || S)
if (signature.length != 64) {
throw Exception(
'Assertion signature verification failed (Ed25519): invalid signature length ${signature.length}, expected 64 bytes.');
}
final pubKey = crypto_api.SimplePublicKey(
xBytes,
type: crypto_api.KeyPairType.ed25519,
);
final verified = await crypto_api.Ed25519().verify(
message,
signature: crypto_api.Signature(signature, publicKey: pubKey),
);
if (!verified) {
throw Exception('Assertion signature verification failed (Ed25519).');
}
}