All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quorum.tessera.nacl.jnacl.JnaclSecretBox Maven / Gradle / Ivy

There is a newer version: 0.11.0.30092019161842
Show newest version
package com.quorum.tessera.nacl.jnacl;

import com.neilalexander.jnacl.crypto.curve25519xsalsa20poly1305;

/**
 * An implementation of {@link SecretBox} that delegates to the JNaCL static methods
 */
public class JnaclSecretBox implements SecretBox {

    @Override
    public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) {
        return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey);
    }

    @Override
    public int cryptoBoxAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey) {
        return curve25519xsalsa20poly1305.crypto_box_afternm(output, message, messageLength, nonce, sharedKey);
    }

    @Override
    public int cryptoBoxOpenAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey) {
        return curve25519xsalsa20poly1305.crypto_box_open_afternm(output, message, messageLength, nonce, sharedKey);
    }

    @Override
    public int cryptoBoxKeypair(final byte[] publicKey, final byte[] privateKey) {
        return curve25519xsalsa20poly1305.crypto_box_keypair(publicKey, privateKey);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy