class BLS {

  public static boolean aggregateVerify(
      List<BLSPublicKey> publicKeys, List<Bytes> messages, BLSSignature signature) {
    checkArgument(
        publicKeys.size() == messages.size(),
        "Number of public keys and number of messages differs.");
    if (publicKeys.isEmpty()) return false;
    // Check that there are no duplicate messages
    if (new HashSet<>(messages).size() != messages.size()) return false;
    List<PublicKeyMessagePair> publicKeyMessagePairs =
        Streams.zip(
                publicKeys.stream(),
                messages.stream(),
                (pk, msg) -> new PublicKeyMessagePair(pk.getPublicKey(), msg))
            .collect(Collectors.toList());
    return signature.getSignature().verify(publicKeyMessagePairs);
  }

}