### Question:
Signature { public static Signature aggregate(List<Signature> signatures) { if (signatures.isEmpty()) { throw new IllegalArgumentException("Parameter list is empty"); } return signatures.stream().reduce(Signature::combine).get(); } Signature(G2Point point); static Signature aggregate(List<Signature> signatures); static Signature decode(Bytes bytes); Signature combine(Signature signature); Bytes encode(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test void testAggregatedSignature() { byte[] message = "Hello".getBytes(UTF_8); List<SignatureAndPublicKey> sigs = getSignaturesAndPublicKeys(message); SignatureAndPublicKey sigAndPubKey = SignatureAndPublicKey.aggregate(sigs); Boolean isValid = BLS12381.verify(sigAndPubKey, message, 48); assertTrue(isValid); }
@Test void testCorruptedMessage() { byte[] message = "Hello".getBytes(UTF_8); List<SignatureAndPublicKey> sigs = getSignaturesAndPublicKeys(message); SignatureAndPublicKey sigAndPubKey = SignatureAndPublicKey.aggregate(sigs); byte[] corruptedMessage = "Not Hello".getBytes(UTF_8); Boolean isValid = BLS12381.verify(sigAndPubKey, corruptedMessage, 48); assertFalse(isValid); }
@Test void testCorruptedSignature() { byte[] message = "Hello".getBytes(UTF_8); List<SignatureAndPublicKey> sigs = getSignaturesAndPublicKeys(message); KeyPair keyPair = KeyPair.random(); byte[] notHello = "Not Hello".getBytes(UTF_8); SignatureAndPublicKey additionalSignature = BLS12381.sign(keyPair, notHello, 48); sigs.add(additionalSignature); SignatureAndPublicKey sigAndPubKey = SignatureAndPublicKey.aggregate(sigs); Boolean isValid = BLS12381.verify(sigAndPubKey, message, 48); assertFalse(isValid); }
@Test void testNoSigs() { assertThrows(IllegalArgumentException.class, () -> { Signature.aggregate(Collections.emptyList()); }); }
@Test void testNoSigsAndPubKeys() { assertThrows(IllegalArgumentException.class, () -> { SignatureAndPublicKey.aggregate(Collections.emptyList()); }); }