class CertificateVerify {

  public static boolean verify(
      final byte[] signature,
      final byte[] data,
      final PublicKey publicKey,
      final boolean isClient) {
    final byte[] prefix = isClient ? CLIENT_PREFIX : SERVER_PREFIX;
    final byte[] toVerify = Bytes.concat(prefix, data);

    try {
      final Signature sig = Signature.getInstance(ALGORITHM);
      sig.setParameter(PARAMETER_SPEC);

      sig.initVerify(publicKey);
      sig.update(toVerify);
      return sig.verify(signature);
    } catch (final GeneralSecurityException e) {
      throw new RuntimeException(e);
    }
  }

}