corda / net.corda.core.crypto / java.security.PublicKey / isValid

isValid

fun PublicKey.isValid(content: ByteArray, signature: DigitalSignature): Boolean

Utility to simplify the act of verifying a signature. In comparison to verify if the key and signature do not match it returns false rather than throwing an exception. Normally you should use the function which throws, as it avoids the risk of failing to test the result, but this is for uses such as java.security.Signature.verify implementations.

Exceptions

InvalidKeyException - if the key to verify the signature with is not valid (i.e. wrong key type for the signature).

SignatureException - if the signature is invalid (i.e. damaged).

IllegalArgumentException - if the signature scheme is not supported or if any of the clear or signature data is empty.

IllegalStateException - if this is a CompositeKey, because verification of composite key signatures is not supported.

Return
whether the signature is correct for this key.