class Jnacl implements Encryptor {

    @Override
    public byte[] sealAfterPrecomputation(final byte[] message, final Nonce nonce, final SharedKey sharedKey) {

        final byte[] paddedMessage = new byte[message.length + crypto_secretbox_ZEROBYTES];
        final byte[] output = new byte[message.length + crypto_secretbox_ZEROBYTES];

        LOGGER.debug("Sealing message using nonce {} and shared key {}", nonce, sharedKey);

        System.arraycopy(message, 0, paddedMessage, crypto_secretbox_ZEROBYTES, message.length);
        final int jnaclResult =
                secretBox.cryptoBoxAfternm(
                        output, paddedMessage, paddedMessage.length, nonce.getNonceBytes(), sharedKey.getKeyBytes());

        if (jnaclResult == -1) {
            LOGGER.error("Could not create sealed payload using shared key {}", sharedKey);
            throw new EncryptorException("jnacl could not seal the payload using the shared key");
        }

        LOGGER.debug(
                "Created sealed payload using nonce {} and shared key {}",
                nonce,
                sharedKey);

        return extract(output, crypto_secretbox_BOXZEROBYTES);
    }

    public  Jnacl(final SecureRandom secureRandom, final SecretBox secretBox);

}