@Test
/**
 * This is a very simple test for the randomness of the nonce. The test simply checks that the
 * multiple ciphertexts of the same message are distinct.
 */
public void testRandomNonce() throws Exception {

  final int samples = 1 << 17;
  byte[] key = Random.randBytes(16);
  byte[] message = new byte[0];
  byte[] aad = new byte[0];
  AesGcmSiv gcm = new AesGcmSiv(key);
  HashSet<String> ciphertexts = new HashSet<String>();
  for (int i = 0; i < samples; i++) {
    byte[] ct = gcm.encrypt(message, aad);
    String ctHex = TestUtil.hexEncode(ct);
    assertFalse(ciphertexts.contains(ctHex));
    ciphertexts.add(ctHex);
  }
}