### Question:
JnaclSecretBox implements SecretBox { @Override public int cryptoBoxKeypair(final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_keypair(publicKey, privateKey); }  @Override int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey); @Override int cryptoBoxAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxOpenAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxKeypair(final byte[] publicKey, final byte[] privateKey);  }### Answer:
@Test public void generatingNewKeysSucceedsIfArraysAreBigEnough() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; final int success = this.secretBox.cryptoBoxKeypair(publicKey, privateKey); assertThat(success).isEqualTo(0); }
@Test public void generatingNewsKeysFailsIfPublicKeyTooSmall() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES-1]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; final Throwable throwable = catchThrowable(() -> this.secretBox.cryptoBoxKeypair(publicKey, privateKey)); assertThat(throwable).isInstanceOf(ArrayIndexOutOfBoundsException.class); }
@Test public void generatingNewsKeysFailsIfPrivateKeyTooSmall() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES-1]; final Throwable throwable = catchThrowable(() -> this.secretBox.cryptoBoxKeypair(publicKey, privateKey)); assertThat(throwable).isInstanceOf(ArrayIndexOutOfBoundsException.class); }