2929public class SealedBoxUtility {
3030
3131
32- public static final int crypto_box_NONCEBYTES = 24 ;
32+ public static final int CRYPTO_BOX_NONCEBYTES = 24 ;
3333 //public static final int crypto_box_PUBLICKEYBYTES = 32;
3434 //public static final int crypto_box_MACBYTES = 16;
3535 //public static final int crypto_box_SEALBYTES = (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES);
@@ -45,12 +45,12 @@ public class SealedBoxUtility {
4545 * @return encrypted message
4646 * @throws GeneralSecurityException
4747 */
48- public static byte [] crypto_box_seal (byte [] receiverPubKey , byte [] clearText ) throws GeneralSecurityException {
48+ public static byte [] cryptoBoxSeal (byte [] receiverPubKey , byte [] clearText ) throws GeneralSecurityException {
4949
5050 // create ephemeral keypair for sender
5151 TweetNaclFast .Box .KeyPair ephkeypair = TweetNaclFast .Box .keyPair ();
5252 // create nonce
53- byte [] nonce = crypto_box_seal_nonce (ephkeypair .getPublicKey (), receiverPubKey );
53+ byte [] nonce = cryptoBoxSealNonce (ephkeypair .getPublicKey (), receiverPubKey );
5454 TweetNaclFast .Box box = new TweetNaclFast .Box (receiverPubKey , ephkeypair .getSecretKey ());
5555 byte [] ciphertext = box .box (clearText , nonce );
5656 if (ciphertext == null )
@@ -73,23 +73,22 @@ public static byte[] crypto_box_seal(byte[] receiverPubKey, byte[] clearText) th
7373 * @param mypk my own public key
7474 * @return the nonce computed using Blake2b generic hash
7575 */
76- public static byte [] crypto_box_seal_nonce (byte [] senderpk , byte [] mypk ){
76+ public static byte [] cryptoBoxSealNonce (byte [] senderpk , byte [] mypk ){
7777 // C source ported from libsodium
7878 // crypto_generichash_state st;
7979 //
80- // crypto_generichash_init(&st, NULL, 0U, crypto_box_NONCEBYTES );
80+ // crypto_generichash_init(&st, NULL, 0U, CRYPTO_BOX_NONCEBYTES );
8181 // crypto_generichash_update(&st, pk1, crypto_box_PUBLICKEYBYTES);
8282 // crypto_generichash_update(&st, pk2, crypto_box_PUBLICKEYBYTES);
83- // crypto_generichash_final(&st, nonce, crypto_box_NONCEBYTES );
83+ // crypto_generichash_final(&st, nonce, CRYPTO_BOX_NONCEBYTES );
8484 //
8585 // return 0;
86- //final org.bouncycastle.jcajce.provider.digest.Blake2b blake2b = Blake2b.Digest.newInstance( crypto_box_NONCEBYTES );
87- final Blake2bDigest blake2b = new Blake2bDigest ( crypto_box_NONCEBYTES *8 );
86+ final Blake2bDigest blake2b = new Blake2bDigest ( CRYPTO_BOX_NONCEBYTES *8 );
8887 blake2b .update (senderpk , 0 , senderpk .length );
8988 blake2b .update (mypk , 0 , mypk .length );
90- byte [] nonce = new byte [crypto_box_NONCEBYTES ];
89+ byte [] nonce = new byte [CRYPTO_BOX_NONCEBYTES ];
9190 blake2b .doFinal (nonce , 0 );
92- if (nonce == null || nonce .length !=crypto_box_NONCEBYTES ) throw new IllegalArgumentException ("Blake2b hashing failed" );
91+ if (nonce == null || nonce .length !=CRYPTO_BOX_NONCEBYTES ) throw new IllegalArgumentException ("Blake2b hashing failed" );
9392 return nonce ;
9493 }
9594
0 commit comments