-
- All Implemented Interfaces:
-
com.goterl.lazysodium.interfaces.AEAD.Lazy,com.goterl.lazysodium.interfaces.AEAD.Native,com.goterl.lazysodium.interfaces.Auth.Lazy,com.goterl.lazysodium.interfaces.Auth.Native,com.goterl.lazysodium.interfaces.Base,com.goterl.lazysodium.interfaces.Box.Lazy,com.goterl.lazysodium.interfaces.Box.Native,com.goterl.lazysodium.interfaces.DiffieHellman.Lazy,com.goterl.lazysodium.interfaces.DiffieHellman.Native,com.goterl.lazysodium.interfaces.GenericHash.Lazy,com.goterl.lazysodium.interfaces.GenericHash.Native,com.goterl.lazysodium.interfaces.Hash.Lazy,com.goterl.lazysodium.interfaces.Hash.Native,com.goterl.lazysodium.interfaces.Helpers.Lazy,com.goterl.lazysodium.interfaces.Helpers.Native,com.goterl.lazysodium.interfaces.KeyDerivation.Lazy,com.goterl.lazysodium.interfaces.KeyDerivation.Native,com.goterl.lazysodium.interfaces.KeyExchange.Lazy,com.goterl.lazysodium.interfaces.KeyExchange.Native,com.goterl.lazysodium.interfaces.Padding.Lazy,com.goterl.lazysodium.interfaces.Padding.Native,com.goterl.lazysodium.interfaces.PwHash.Lazy,com.goterl.lazysodium.interfaces.PwHash.Native,com.goterl.lazysodium.interfaces.Random,com.goterl.lazysodium.interfaces.Ristretto255.Lazy,com.goterl.lazysodium.interfaces.Ristretto255.Native,com.goterl.lazysodium.interfaces.SecretBox.Lazy,com.goterl.lazysodium.interfaces.SecretBox.Native,com.goterl.lazysodium.interfaces.SecretStream.Lazy,com.goterl.lazysodium.interfaces.SecretStream.Native,com.goterl.lazysodium.interfaces.SecureMemory.Lazy,com.goterl.lazysodium.interfaces.SecureMemory.Native,com.goterl.lazysodium.interfaces.ShortHash.Lazy,com.goterl.lazysodium.interfaces.ShortHash.Native,com.goterl.lazysodium.interfaces.Sign.Lazy,com.goterl.lazysodium.interfaces.Sign.Native,com.goterl.lazysodium.interfaces.Stream.Lazy,com.goterl.lazysodium.interfaces.Stream.Native
public abstract class LazySodium implements Base, Random, AEAD.Native, AEAD.Lazy, GenericHash.Native, GenericHash.Lazy, ShortHash.Native, ShortHash.Lazy, SecureMemory.Native, SecureMemory.Lazy, Auth.Native, Auth.Lazy, SecretStream.Native, SecretStream.Lazy, Stream.Native, Stream.Lazy, Padding.Native, Padding.Lazy, Helpers.Native, Helpers.Lazy, PwHash.Native, PwHash.Lazy, Hash.Native, Hash.Lazy, Sign.Native, Sign.Lazy, Box.Native, Box.Lazy, SecretBox.Native, SecretBox.Lazy, KeyExchange.Native, KeyExchange.Lazy, KeyDerivation.Native, KeyDerivation.Lazy, DiffieHellman.Native, DiffieHellman.Lazy, Ristretto255.Native, Ristretto255.Lazy
-
-
Constructor Summary
Constructors Constructor Description LazySodium()LazySodium(Charset charset)LazySodium(MessageEncoder messageEncoder)LazySodium(Charset charset, MessageEncoder messageEncoder)
-
Method Summary
Modifier and Type Method Description intsodiumInit()StringsodiumBin2Hex(Array<byte> bin)Binary to hexadecimal. Array<byte>sodiumHex2Bin(String hex)Hexadecimal to binary. StringtoHexStr(Array<byte> bs)Array<byte>toBinary(String hex)static StringtoHex(Array<byte> bin)Bytes to hexadecimal. static Array<byte>toBin(String hex)Hexadecimal string to bytes. longrandomBytesRandom()Return a unsigned int byte 0 and 0xffffffff included. voidrandomBytesBuf(Array<byte> buff, int size)Fill a buffer with random bytes. Array<byte>randomBytesBuf(int size)Get a random number of bytes. Array<byte>nonce(int size)Get a random number of bytes to use in a nonce. longrandomBytesUniform(int upperBound)Returns an unpredictable value between 0 and upperBound (excluded).Unlike randombytes_random() % upper_bound, it guarantees a uniform distributionof the possible output values even when upper_bound is not a power of 2. voidrandomBytesDeterministic(Array<byte> buff, int size, Array<byte> seed)Fill a buffer with deterministically random bytes given a seed. Array<byte>randomBytesDeterministic(int size, Array<byte> seed)Get deterministically random bytes given a seed. booleansodiumPad(IntByReference paddedBuffLen, Pointer buf, int unpaddedBufLen, int blockSize, int maxBufLen)Adds extra padding to a buffer {@code buf}whoseoriginal size is{@code unpaddedBufLen}in orderto extend its total length to a multiple of{@code blocksize}.booleansodiumUnpad(IntByReference unPaddedBuffLen, Pointer buf, int paddedBufLen, int blockSize)Computes the original, unpadded length of a message previously padded using sodiumPad. voidsodiumMemZero(Array<byte> pnt, int len)The sodium_memzero() function tries to effectively zero len bytes starting at pnt,even if optimizations are being applied to the code. booleansodiumMLock(Array<byte> array, int len)Locks at least len bytes of memory from the array.This can help avoid swapping sensitive data to disk. booleansodiumMUnlock(Array<byte> array, int len)Unlocks at least len bytes of memory from the array. PointersodiumMalloc(int size)Returns a pointer from which exactlysize contiguous bytes of memory can be accessed. PointersodiumAllocArray(int count, int size)Returns a pointer from whichcount objects that are size bytes of memory each can be accessed. voidsodiumFree(Pointer p)Unlocks and deallocates memory allocated using sodiumMalloc or sodiumAllocArray}. booleansodiumMProtectNoAccess(Pointer ptr)Makes a region allocated using sodiumMalloc or sodiumAllocArray}inaccessible. booleansodiumMProtectReadOnly(Pointer ptr)Marks a region allocated using sodiumMalloc or sodiumAllocArray}as read-only.Attempting to modify the data will cause the process to terminate. booleansodiumMProtectReadWrite(Pointer ptr)Marks a region allocated using sodiumMalloc or sodiumAllocArray}as readable and writable, after having been protected using sodiumMProtectReadOnly or sodiumMProtectNoAccess}/ voidcryptoKdfKeygen(Array<byte> masterKey)Creates a master key. booleancryptoKdfDeriveFromKey(Array<byte> subKey, int subKeyLen, long subKeyId, Array<byte> context, Array<byte> masterKey)Derive a subkey from a master key. KeycryptoKdfKeygen()Auto generates a master key and returnsit in string format.The reason why this does not return a string via the normal 'masterKey.getBytes()'is because the resulting string is mangled. KeycryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey)Derive a subkey from a master key. booleancryptoKxKeypair(Array<byte> publicKey, Array<byte> secretKey)Generate a public and a secret key. booleancryptoKxSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)Deterministically generate a public and secret key.Store the seed somewhere if you want to generate thesekeys again. booleancryptoKxClientSessionKeys(Array<byte> rx, Array<byte> tx, Array<byte> clientPk, Array<byte> clientSk, Array<byte> serverPk)This function computes a pair of shared keys(rx and tx) using the client's public key clientPk,the client's secret key clientSk and the server's public key serverPk. booleancryptoKxServerSessionKeys(Array<byte> rx, Array<byte> tx, Array<byte> serverPk, Array<byte> serverSk, Array<byte> clientPk)This function computes a pair of shared keys(rx and tx) using the client's public key clientPk,the server's secret key serverSk and the server's public key serverPk. KeyPaircryptoKxKeypair()Generate a public and secret key. KeyPaircryptoKxKeypair(Array<byte> seed)Deterministically generate a public and secret key.Store the seed somewhere if you want to generate thesekeys again. SessionPaircryptoKxClientSessionKeys(KeyPair clientKeyPair, KeyPair serverKeyPair)Generate a client's session keys. SessionPaircryptoKxClientSessionKeys(KeyPair clientKeyPair, Key serverPublicKey)Generate a client's session keys. SessionPaircryptoKxServerSessionKeys(Key serverPk, Key serverSk, Key clientPk)Computes a pair of shared keys (server-side)(rx and tx) using the client's public key clientPk,the server's secret key serverSk and the server's public key serverPk. SessionPaircryptoKxClientSessionKeys(Key clientPk, Key clientSk, Key serverPk)Generate a client's session keys. SessionPaircryptoKxServerSessionKeys(KeyPair serverKeyPair, KeyPair clientKeyPair)Generate a server's session keys. SessionPaircryptoKxServerSessionKeys(KeyPair serverKeyPair, Key clientPublicKey)Generate a server's session keys. booleancryptoPwHash(Array<byte> outputHash, int outputHashLen, Array<byte> password, int passwordLen, Array<byte> salt, long opsLimit, NativeLong memLimit, PwHash.Alg alg)Based on a password you provide, hash thatpassword and put the output into {@code outputHash}.Take note that the output of this does NOT output a traditionalArgon 2 string as the underlying native implementation calls argon2id_hash_rawinstead of argon2id_hash_encoded.booleancryptoPwHashStr(Array<byte> outputStr, Array<byte> password, int passwordLen, long opsLimit, NativeLong memLimit)Hashes a password and stores it into an array. booleancryptoPwHashStrVerify(Array<byte> hash, Array<byte> password, int passwordLen)Verifies a hashed password. PwHash.NeedsRehashResultcryptoPwHashStrNeedsRehash(Array<byte> hash, long opsLimit, NativeLong memLimit)Checks whether the hash needs a rehash. StringcryptoPwHash(String password, int lengthOfHash, Array<byte> salt, long opsLimit, NativeLong memLimit, PwHash.Alg alg)Hashes a given password. StringcryptoPwHashString(String password, long opsLimit, NativeLong memLimit)The most minimal way of hashing a given password to a standard-format string including all used parameters. StringcryptoPwHashStr(String password, long opsLimit, NativeLong memLimit)The most minimal way of hashing a given password to a string including all used parameters. StringcryptoPwHashStrRemoveNulls(String password, long opsLimit, NativeLong memLimit)Hashes a string to a string representation including the used parameters, and removes alluseless null bytes. booleancryptoPwHashStringVerify(String hash, String password)Verifies a password represented as a standard-formatted hash, generated by cryptoPwHashString. booleancryptoPwHashStrVerify(String hash, String password)Verifies a password represented as a long encoded string generated by cryptoPwHashStr or cryptoPwHashStrRemoveNulls. PwHash.NeedsRehashResultcryptoPwHashStringNeedsRehash(String hash, long opsLimit, NativeLong memLimit)Checks whether the hash needs a rehash. booleancryptoHashSha256(Array<byte> out, Array<byte> in, int inLen)booleancryptoHashSha256Init(Hash.State256 state)booleancryptoHashSha256Update(Hash.State256 state, Array<byte> in, int inLen)booleancryptoHashSha256Final(Hash.State256 state, Array<byte> out)booleancryptoHashSha512(Array<byte> out, Array<byte> in, int inLen)booleancryptoHashSha512Init(Hash.State512 state)booleancryptoHashSha512Update(Hash.State512 state, Array<byte> in, int inLen)booleancryptoHashSha512Final(Hash.State512 state, Array<byte> out)StringcryptoHashSha256(String message)StringcryptoHashSha512(String message)booleancryptoHashSha256Update(Hash.State256 state, String messagePart)StringcryptoHashSha256Final(Hash.State256 state)booleancryptoHashSha512Update(Hash.State512 state, String messagePart)StringcryptoHashSha512Final(Hash.State512 state)voidcryptoSecretBoxKeygen(Array<byte> key)Creates a random key. booleancryptoSecretBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message using a key generated by cryptoSecretBoxKeygen. booleancryptoSecretBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts and verifies a message using a key generatedby cryptoSecretBoxKeygen. booleancryptoSecretBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message. booleancryptoSecretBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts a message with the mac and the cipher providedseparately. voidcryptoSecretBoxXChaCha20Poly1305Keygen(Array<byte> key)Creates a random key for the XChaCha20Poly1305 variant. booleancryptoSecretBoxXChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message by the XChaCha20Poly1305 variant using a key generated by cryptoSecretBoxKeygen. booleancryptoSecretBoxXChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts and verifies a message using a key generatedby cryptoSecretBoxXChaCha20Poly1305Keygen. booleancryptoSecretBoxXChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)Encrypts a message using the XChaCha20Poly1305 variant. booleancryptoSecretBoxXChaCha20Poly1305OpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)Decrypts a message with the mac and the cipher providedseparately, using the XChaCha20Poly1305 variant. KeycryptoSecretBoxKeygen()Generates a secret symmetric key. StringcryptoSecretBoxEasy(String message, Array<byte> nonce, Key key)Encrypts a message. StringcryptoSecretBoxOpenEasy(String cipher, Array<byte> nonce, Key key)Decrypts a message. DetachedEncryptcryptoSecretBoxDetached(String message, Array<byte> nonce, Key key)Encrypts a message with the mac separately StringcryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, Array<byte> nonce, Key key)Decrypts a message. booleancryptoScalarMultBase(Array<byte> publicKey, Array<byte> secretKey)KeycryptoScalarMultBase(Key secretKey)Generate a public key from a private key. booleancryptoScalarMult(Array<byte> shared, Array<byte> secretKey, Array<byte> publicKey)KeycryptoScalarMult(Key secretKey, Key publicKey)Generate a shared key from another user's public keyand a secret key. booleancryptoBoxKeypair(Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)booleancryptoBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxBeforeNm(Array<byte> k, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxEasyAfterNm(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxOpenEasyAfterNm(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxDetachedAfterNm(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxOpenDetachedAfterNm(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxSeal(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> publicKey)booleancryptoBoxSealOpen(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305Keypair(Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305SeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)booleancryptoBoxCurve25519XChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305OpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305BeforeNm(Array<byte> k, Array<byte> publicKey, Array<byte> secretKey)booleancryptoBoxCurve25519XChaCha20Poly1305EasyAfterNm(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxCurve25519XChaCha20Poly1305OpenEasyAfterNm(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxCurve25519XChaCha20Poly1305DetachedAfterNm(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxCurve25519XChaCha20Poly1305OpenDetachedAfterNm(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)booleancryptoBoxCurve25519XChaCha20Poly1305Seal(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> publicKey)booleancryptoBoxCurve25519XChaCha20Poly1305SealOpen(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> publicKey, Array<byte> secretKey)KeyPaircryptoBoxKeypair()Generate a secret and public key. KeyPaircryptoBoxSeedKeypair(Array<byte> seed)Generate a public and secret key deterministically. StringcryptoBoxEasy(String message, Array<byte> nonce, KeyPair keyPair)Encrypts a message. StringcryptoBoxOpenEasy(String cipherText, Array<byte> nonce, KeyPair keyPair)Decrypts a previously encrypted message. StringcryptoBoxBeforeNm(Array<byte> publicKey, Array<byte> secretKey)If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations. StringcryptoBoxBeforeNm(KeyPair keyPair)If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations. StringcryptoBoxEasyAfterNm(String message, Array<byte> nonce, String sharedSecretKey)Encrypt a message. StringcryptoBoxOpenEasyAfterNm(String cipher, Array<byte> nonce, String sharedSecretKey)Decrypt a message. DetachedEncryptcryptoBoxDetachedAfterNm(String message, Array<byte> nonce, String sharedSecretKey)Encrypt a message but allow for storage ofthe mac separately. DetachedDecryptcryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, Array<byte> nonce, String sharedSecretKey)Decrypt a message. StringcryptoBoxSealEasy(String message, Key publicKey)Encrypts a message. StringcryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair)Decrypts a previously encrypted message. booleancryptoSignInit(Sign.StateCryptoSign state)Useful for signing a multi-part message (Ed25519ph).If the message can fit in memory and can be supplied as asingle chunk, the single-part API should be preferred.This function must be called before the first crypto_sign_update() call. booleancryptoSignUpdate(Sign.StateCryptoSign state, Array<byte> chunk, int chunkLength)Add a new chunk of length chunkLen bytes to themessage that will eventually be signed. booleancryptoSignFinalCreate(Sign.StateCryptoSign state, Array<byte> sig, Array<byte> sk)This function computes a signature for the previously supplied message,using the secret key sk and puts it into sig. booleancryptoSignFinalVerify(Sign.StateCryptoSign state, Array<byte> sig, Array<byte> pk)Verifies that sig is a valid signature for the message whosecontent has been previously supplied using crypto_update(),using the public key pk. booleancryptoSignKeypair(Array<byte> publicKey, Array<byte> secretKey)Generate a signing keypair (ed25519). booleancryptoSignSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)Deterministically generate a public and secret key. booleancryptoSign(Array<byte> signedMessage, Array<byte> message, int messageLen, Array<byte> secretKey)Sign a message. booleancryptoSignOpen(Array<byte> message, Array<byte> signedMessage, int signedMessageLen, Array<byte> publicKey)Verify a signed message. booleancryptoSignDetached(Array<byte> signature, Array<byte> message, int messageLen, Array<byte> secretKey)Returns a signature for a message. booleancryptoSignVerifyDetached(Array<byte> signature, Array<byte> message, int messageLen, Array<byte> publicKey)Verifies that {@code signature}is valid for the{@code message}.booleanconvertPublicKeyEd25519ToCurve25519(Array<byte> curve, Array<byte> ed)Converts a public ed25519 key to a public curve25519 key. booleanconvertSecretKeyEd25519ToCurve25519(Array<byte> curve, Array<byte> ed)Converts a secret ed25519 key to a secret curve25519 key. booleancryptoSignEd25519SkToSeed(Array<byte> seed, Array<byte> ed)Extracts the seed value from a secret ed25519 key. booleancryptoSignEd25519SkToPk(Array<byte> publicKey, Array<byte> secretKey)Extracts the ed25519 public key from a secret ed25519 key. KeyPaircryptoSignKeypair()Generate a signing keypair (ed25519). KeyPaircryptoSignSeedKeypair(Array<byte> seed)Generate a signing keypair deterministically. KeyPaircryptoSignSecretKeyPair(Key secretKey)Generate a signing keypair (ed25519), given a secret ed25519 key. StringcryptoSign(String message, String secretKey)Sign a message. StringcryptoSign(String message, Key secretKey)Sign a message. StringcryptoSignOpen(String signedMessage, Key publicKey)Checks that a message is validly signed by a public key. StringcryptoSignDetached(String message, Key secretKey)Returns a signature for a message. booleancryptoSignVerifyDetached(String signature, String message, Key publicKey)Verifies that {@code signature}is valid for the{@code message}.KeyPairconvertKeyPairEd25519ToCurve25519(KeyPair ed25519KeyPair)Converts a ed25519 keypair to a curve25519 keypair. Array<byte>cryptoSignEd25519SkToSeed(Key secretKey)Extracts the seed from an ed25519 secret key voidcryptoSecretStreamKeygen(Array<byte> key)Generate a secret stream key. booleancryptoSecretStreamInitPush(SecretStream.State state, Array<byte> header, Array<byte> key)Initialises encryption with a state and a key. booleancryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, byte tag)Encrypt a {@code message}.booleancryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<byte> message, int messageLen, byte tag)Encrypt a {@code message}.booleancryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, byte tag)Encrypt a {@code message}.booleancryptoSecretStreamInitPull(SecretStream.State state, Array<byte> header, Array<byte> key)Initialises decryption using a state and a key. booleancryptoSecretStreamPull(SecretStream.State state, Array<byte> message, Array<long> messageLen, Array<byte> tag, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen)Decrypt a message. booleancryptoSecretStreamPull(SecretStream.State state, Array<byte> message, Array<byte> tag, Array<byte> cipher, int cipherLen)Decrypt a message without additional data. KeycryptoSecretStreamKeygen()Generates a key. SecretStream.StatecryptoSecretStreamInitPush(Array<byte> header, Key key)Initialise encryption. StringcryptoSecretStreamPush(SecretStream.State state, String message, byte tag)Encrypt a {@code message}.SecretStream.StatecryptoSecretStreamInitPull(Array<byte> header, Key key)Initialises decryption using a state and a key. StringcryptoSecretStreamPull(SecretStream.State state, String cipher, Array<byte> tag)Decrypt a message without additional data. voidcryptoSecretStreamRekey(SecretStream.State state)Explicitly rekeys. voidcryptoStreamChaCha20Keygen(Array<byte> key)booleancryptoStreamChaCha20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamChaCha20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamChaCha20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)booleancryptoStreamChacha20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)Backward-compatible method name. voidcryptoStreamChaCha20IetfKeygen(Array<byte> key)booleancryptoStreamChaCha20Ietf(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamChaCha20IetfXor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamChaCha20IetfXorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)booleancryptoStreamChacha20IetfXorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)Backward-compatible method name. voidcryptoStreamSalsa20Keygen(Array<byte> key)booleancryptoStreamSalsa20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamSalsa20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamSalsa20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)voidcryptoStreamXSalsa20Keygen(Array<byte> key)booleancryptoStreamXSalsa20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamXSalsa20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)booleancryptoStreamXSalsa20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)KeycryptoStreamKeygen(Stream.Method method)Array<byte>cryptoStream(Array<byte> nonce, Key key, Stream.Method method)Generate 20 bytes of keystream Array<byte>cryptoStream(int bytes, Array<byte> nonce, Key key, Stream.Method method)StringcryptoStreamXor(String message, Array<byte> nonce, Key key, Stream.Method method)StringcryptoStreamXorDecrypt(String cipher, Array<byte> nonce, Key key, Stream.Method method)StringcryptoStreamXorIc(String message, Array<byte> nonce, long ic, Key key, Stream.Method method)StringcryptoStreamXorIcDecrypt(String cipher, Array<byte> nonce, long ic, Key key, Stream.Method method)booleancryptoAuth(Array<byte> tag, Array<byte> in, int inLen, Array<byte> key)Computes a tag for the message in, whose length is inLen bytes, and the key k. booleancryptoAuthVerify(Array<byte> tag, Array<byte> in, int inLen, Array<byte> key)Verifies that the tag stored at h is avalid tag for the message in whose lengthis inLen bytes, and the key k. voidcryptoAuthKeygen(Array<byte> k)Generate an authentication key. KeycryptoAuthKeygen()Generate an authentication key. StringcryptoAuth(String message, Key key)Computes a tag for the message in. booleancryptoAuthVerify(String tag, String message, Key key)Verifies that the tagvalid tag for the message. voidcryptoAuthHMACSha256Keygen(Array<byte> key)booleancryptoAuthHMACSha256(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha256Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha256Init(Auth.StateHMAC256 state, Array<byte> key, int keyLen)booleancryptoAuthHMACSha256Update(Auth.StateHMAC256 state, Array<byte> in, int inLen)booleancryptoAuthHMACSha256Final(Auth.StateHMAC256 state, Array<byte> out)voidcryptoAuthHMACSha512Keygen(Array<byte> key)booleancryptoAuthHMACSha512(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha512Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha512Init(Auth.StateHMAC512 state, Array<byte> key, int keyLen)booleancryptoAuthHMACSha512Update(Auth.StateHMAC512 state, Array<byte> in, int inLen)booleancryptoAuthHMACSha512Final(Auth.StateHMAC512 state, Array<byte> out)voidcryptoAuthHMACSha512256Keygen(Array<byte> key)booleancryptoAuthHMACSha512256(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha512256Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)booleancryptoAuthHMACSha512256Init(Auth.StateHMAC512256 state, Array<byte> key, int keyLen)booleancryptoAuthHMACSha512256Update(Auth.StateHMAC512256 state, Array<byte> in, int inLen)booleancryptoAuthHMACSha512256Final(Auth.StateHMAC512256 state, Array<byte> out)KeycryptoAuthHMACShaKeygen(Auth.Type type)StringcryptoAuthHMACSha(Auth.Type type, String in, Key key)booleancryptoAuthHMACShaVerify(Auth.Type type, String h, String in, Key key)booleancryptoAuthHMACShaInit(Auth.StateHMAC256 state, Key key)booleancryptoAuthHMACShaUpdate(Auth.StateHMAC256 state, String in)StringcryptoAuthHMACShaFinal(Auth.StateHMAC256 state)booleancryptoAuthHMACShaInit(Auth.StateHMAC512 state, Key key)booleancryptoAuthHMACShaUpdate(Auth.StateHMAC512 state, String in)StringcryptoAuthHMACShaFinal(Auth.StateHMAC512 state)booleancryptoAuthHMACShaInit(Auth.StateHMAC512256 state, Key key)booleancryptoAuthHMACShaUpdate(Auth.StateHMAC512256 state, String in)StringcryptoAuthHMACShaFinal(Auth.StateHMAC512256 state)booleancryptoShortHash(Array<byte> out, Array<byte> in, int inLen, Array<byte> key)Short-input hash some text. voidcryptoShortHashKeygen(Array<byte> k)Output a 64-bit key. StringcryptoShortHash(Array<byte> inBytes, Key key)Hash a short message using a key. StringcryptoShortHashStr(String in, Key key)Hash a short string using a key. StringcryptoShortHashHex(String hexIn, Key key)Hash a short hexadecimal string using a key. KeycryptoShortHashKeygen()Generate a 64-bit key for short-input hashing. booleancryptoGenericHash(Array<byte> out, int outLen, Array<byte> in, int inLen, Array<byte> key, int keyLen)Hash a byte array. booleancryptoGenericHash(Array<byte> out, int outLen, Array<byte> in, int inLen)Hash a byte array without a key. booleancryptoGenericHashInit(GenericHash.State state, Array<byte> key, int keyLength, int outLen)Hash multiple parts of a message. booleancryptoGenericHashInit(GenericHash.State state, int outLen)Hash multiple parts of a message without a key booleancryptoGenericHashUpdate(GenericHash.State state, Array<byte> in, int inLen)Update a multi-part hashing with another part. booleancryptoGenericHashFinal(GenericHash.State state, Array<byte> out, int outLen)Now that the hash has finalised, the hash canbe put into {@code out}.voidcryptoGenericHashKeygen(Array<byte> k)Generate a key. KeycryptoGenericHashKeygen()Generate a hashing key. KeycryptoGenericHashKeygen(int size)Generate a hashing key with a size. StringcryptoGenericHash(String in, Key key)Hash a string with a key, so later on youcan verify the hashed string with the key. StringcryptoGenericHash(String in)Hash a string without a key. booleancryptoGenericHashInit(GenericHash.State state, Key key, int outLen)Initialise a multi-part hashing operation. booleancryptoGenericHashUpdate(GenericHash.State state, String in)Hash a part of a multi-part hash. StringcryptoGenericHashFinal(GenericHash.State state, int outLen)Finalise the hashing operation. voidcryptoAeadChaCha20Poly1305Keygen(Array<byte> key)booleancryptoAeadChaCha20Poly1305Encrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)Encrypt a message booleancryptoAeadChaCha20Poly1305Encrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)Encrypt a message (a deprecated overload) booleancryptoAeadChaCha20Poly1305Decrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305Decrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305EncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305EncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305DecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305DecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)voidcryptoAeadChaCha20Poly1305IetfKeygen(Array<byte> key)booleancryptoAeadChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)voidcryptoAeadXChaCha20Poly1305IetfKeygen(Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)booleancryptoAeadXChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)voidcryptoAeadAES256GCMKeygen(Array<byte> key)booleancryptoAeadAES256GCMEncrypt(Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMEncrypt(Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nSec, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMDecrypt(Array<byte> message, Array<long> messageLen, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMDecrypt(Array<byte> message, Array<long> messageLen, Array<byte> nSec, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMEncryptDetached(Array<byte> cipher, Array<byte> mac, Array<long> macLenAddress, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMEncryptDetached(Array<byte> cipher, Array<byte> mac, Array<long> macLenAddress, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nSec, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMDecryptDetached(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> mac, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMDecryptDetached(Array<byte> message, Array<byte> nSec, Array<byte> cipher, int cipherLen, Array<byte> mac, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)booleancryptoAeadAES256GCMIsAvailable()Keykeygen(AEAD.Method method)Stringencrypt(String m, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)Stringencrypt(String m, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)Stringdecrypt(String cipher, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)Stringdecrypt(String cipher, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)DetachedEncryptencryptDetached(String m, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)DetachedEncryptencryptDetached(String m, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)DetachedDecryptdecryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)DetachedDecryptdecryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)booleancryptoCoreRistretto255IsValidPoint(Array<byte> point)Returns whether the passed bytes represent a valid Ristretto255 point. voidcryptoCoreRistretto255Random(Array<byte> point)Chooses a random Ristretto255 point and puts its representation to {@code point}booleancryptoCoreRistretto255FromHash(Array<byte> point, Array<byte> hash)Maps a RISTRETTO255_HASH_BYTES bytes hash to a Ristretto255 pointand puts its representation to {@code point}.booleancryptoScalarmultRistretto255(Array<byte> result, Array<byte> n, Array<byte> point)Multiplies the given Ristretto255 {@code point}by the scalar{@code n}and puts therepresentation of the result into{@code result}.booleancryptoScalarmultRistretto255Base(Array<byte> result, Array<byte> n)Multiplies the Ristretto255 base point by the scalar {@code n}and puts therepresentation of the result into{@code result}.booleancryptoCoreRistretto255Add(Array<byte> result, Array<byte> p, Array<byte> q)Adds two given Ristretto255 points {@code p}and{@code q}and puts the representation ofthe result into{@code result}.booleancryptoCoreRistretto255Sub(Array<byte> result, Array<byte> p, Array<byte> q)Subtracts two given Ristretto255 points {@code p}and{@code q}and puts therepresentation of the result into{@code result}.voidcryptoCoreRistretto255ScalarRandom(Array<byte> scalar)Creates a random scalar value in {@code [0, l[}with{@code L}being the order of theRistretto255 group.voidcryptoCoreRistretto255ScalarReduce(Array<byte> result, Array<byte> scalar)Reduces a possibly larger scalar value to {@code [0, l[}with{@code L}being the orderof the Ristretto255 group.booleancryptoCoreRistretto255ScalarInvert(Array<byte> result, Array<byte> scalar)Calculates the multiplicative inverse of the given scalar value. voidcryptoCoreRistretto255ScalarNegate(Array<byte> result, Array<byte> scalar)Calculates the additive inverse of the given scalar value. voidcryptoCoreRistretto255ScalarComplement(Array<byte> result, Array<byte> scalar)Calculates the result R for the given scalar value such that {@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.voidcryptoCoreRistretto255ScalarAdd(Array<byte> result, Array<byte> x, Array<byte> y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.voidcryptoCoreRistretto255ScalarSub(Array<byte> result, Array<byte> x, Array<byte> y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.voidcryptoCoreRistretto255ScalarMul(Array<byte> result, Array<byte> x, Array<byte> y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.booleancryptoCoreRistretto255IsValidPoint(String point)Returns whether the passed encoded string represents a valid Ristretto255 point. Ristretto255.RistrettoPointcryptoCoreRistretto255Random()Chooses a random Ristretto255 point and returns it. Ristretto255.RistrettoPointcryptoCoreRistretto255FromHash(String hash)Maps a RISTRETTO255_HASH_BYTES bytes hash to a . Ristretto255.RistrettoPointcryptoCoreRistretto255FromHash(Array<byte> hash)Maps a RISTRETTO255_HASH_BYTES bytes hash to a Ristretto255 point. Ristretto255.RistrettoPointcryptoScalarmultRistretto255(BigInteger n, Ristretto255.RistrettoPoint point)Multiplies the given Ristretto255 {@code point}by the scalar{@code n}and returns theresulting point.Ristretto255.RistrettoPointcryptoScalarmultRistretto255(String nEnc, Ristretto255.RistrettoPoint point)Multiplies the given Ristretto255 {@code point}by the scalar{@code n}and returns theresulting point.Ristretto255.RistrettoPointcryptoScalarmultRistretto255(Array<byte> n, Ristretto255.RistrettoPoint point)Multiplies the given Ristretto255 {@code point}by the scalar{@code n}and returns theresulting point.Ristretto255.RistrettoPointcryptoScalarmultRistretto255Base(BigInteger n)Multiplies the Ristretto255 base point by the scalar {@code n}and returns the result.Ristretto255.RistrettoPointcryptoScalarmultRistretto255Base(String nEnc)Multiplies the Ristretto255 base point by the scalar {@code n}and returns the result.Ristretto255.RistrettoPointcryptoScalarmultRistretto255Base(Array<byte> n)Multiplies the Ristretto255 base point by the scalar {@code n}and returns the result.Ristretto255.RistrettoPointcryptoCoreRistretto255Add(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q)Adds two given Ristretto255 points {@code p}and{@code q}and returns the result.Ristretto255.RistrettoPointcryptoCoreRistretto255Sub(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q)Subtracts two given Ristretto255 points {@code p}and{@code q}and returns the result.BigIntegercryptoCoreRistretto255ScalarRandom()Creates a random scalar value in {@code [0, l[}with{@code L}being the order of theRistretto255 group.BigIntegercryptoCoreRistretto255ScalarReduce(BigInteger scalar)Reduces a possibly larger scalar value to {@code [0, l[}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarReduce(String scalarEnc)Reduces a possibly larger scalar value to {@code [0, l[}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarReduce(Array<byte> scalar)Reduces a possibly larger scalar value to {@code [0, L[}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarInvert(BigInteger scalar)Calculates the multiplicative inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarInvert(String scalarEnc)Calculates the multiplicative inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarInvert(Array<byte> scalar)Calculates the multiplicative inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarNegate(BigInteger scalar)Calculates the additive inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarNegate(String scalarEnc)Calculates the additive inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarNegate(Array<byte> scalar)Calculates the additive inverse of the given scalar value. BigIntegercryptoCoreRistretto255ScalarComplement(BigInteger scalar)Calculates the result R for the given scalar value such that {@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarComplement(String scalarEnc)Calculates the result R for the given scalar value such that {@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarComplement(Array<byte> scalar)Calculates the result R for the given scalar value such that {@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(BigInteger x, BigInteger y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(BigInteger x, String y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(String x, BigInteger y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(String x, String y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(String x, Array<byte> y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(Array<byte> x, String y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(BigInteger x, Array<byte> y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(Array<byte> x, BigInteger y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarAdd(Array<byte> x, Array<byte> y)Adds two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(BigInteger x, BigInteger y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(BigInteger x, String y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(String x, BigInteger y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(String x, String y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(String x, Array<byte> y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(Array<byte> x, String y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(BigInteger x, Array<byte> y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(Array<byte> x, BigInteger y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarSub(Array<byte> x, Array<byte> y)Subtracts two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(BigInteger x, BigInteger y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(BigInteger x, String y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(String x, BigInteger y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(String x, String y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(String x, Array<byte> y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(Array<byte> x, String y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(BigInteger x, Array<byte> y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(Array<byte> x, BigInteger y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.BigIntegercryptoCoreRistretto255ScalarMul(Array<byte> x, Array<byte> y)Multiplies two scalars {@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.<T> Tres(int res, T object)booleansuccessful(int res)Stringstr(Array<byte> bs)Converts a byte array to a stringusing a charset. Stringstr(Array<byte> bs, Charset charset)Convert a byte array to a string with a charset.This may not be what you want to use if you're storing this stringin a database for example. Array<byte>bytes(String s)Convert a string to bytes using the configured charset. StringencodeToString(Array<byte> bytes)Encodes the given bytes, using this LazySodium's associated MessageEncoder. Array<byte>decodeFromString(String encoded)Decodes the given string to bytes, using this LazySodium's associated MessageEncoder. booleanwrongLen(Array<byte> bs, int shouldBe)booleanwrongLen(int byteLength, int shouldBe)booleanwrongLen(int byteLength, long shouldBe)Array<byte>removeNulls(Array<byte> bs)Remove all the null bytes from theend of a byte array. abstract SodiumgetSodium()static voidmain(Array<String> args)-
Methods inherited from class com.goterl.lazysodium.interfaces.Base
wrongLen, wrongLen, wrongLen -
Methods inherited from class com.goterl.lazysodium.interfaces.AEAD.Native
cryptoAeadAES256GCMDecrypt, cryptoAeadAES256GCMDecrypt, cryptoAeadAES256GCMDecryptDetached, cryptoAeadAES256GCMDecryptDetached, cryptoAeadAES256GCMEncrypt, cryptoAeadAES256GCMEncrypt, cryptoAeadAES256GCMEncryptDetached, cryptoAeadAES256GCMEncryptDetached, cryptoAeadChaCha20Poly1305Decrypt, cryptoAeadChaCha20Poly1305Decrypt, cryptoAeadChaCha20Poly1305DecryptDetached, cryptoAeadChaCha20Poly1305DecryptDetached, cryptoAeadChaCha20Poly1305Encrypt, cryptoAeadChaCha20Poly1305Encrypt, cryptoAeadChaCha20Poly1305EncryptDetached, cryptoAeadChaCha20Poly1305EncryptDetached, cryptoAeadChaCha20Poly1305IetfDecrypt, cryptoAeadChaCha20Poly1305IetfDecrypt, cryptoAeadChaCha20Poly1305IetfDecryptDetached, cryptoAeadChaCha20Poly1305IetfDecryptDetached, cryptoAeadChaCha20Poly1305IetfEncrypt, cryptoAeadChaCha20Poly1305IetfEncrypt, cryptoAeadChaCha20Poly1305IetfEncryptDetached, cryptoAeadChaCha20Poly1305IetfEncryptDetached, cryptoAeadXChaCha20Poly1305IetfDecrypt, cryptoAeadXChaCha20Poly1305IetfDecrypt, cryptoAeadXChaCha20Poly1305IetfDecryptDetached, cryptoAeadXChaCha20Poly1305IetfDecryptDetached, cryptoAeadXChaCha20Poly1305IetfEncrypt, cryptoAeadXChaCha20Poly1305IetfEncrypt, cryptoAeadXChaCha20Poly1305IetfEncryptDetached, cryptoAeadXChaCha20Poly1305IetfEncryptDetached, cryptoAeadXChaCha20Poly1305IetfKeygen -
Methods inherited from class com.goterl.lazysodium.interfaces.AEAD.Lazy
decrypt, decrypt, decryptDetached, decryptDetached, encrypt, encrypt, encryptDetached, encryptDetached, keygen -
Methods inherited from class com.goterl.lazysodium.interfaces.GenericHash.Native
cryptoGenericHash, cryptoGenericHash, cryptoGenericHashInit, cryptoGenericHashUpdate -
Methods inherited from class com.goterl.lazysodium.interfaces.GenericHash.Lazy
cryptoGenericHashInit -
Methods inherited from class com.goterl.lazysodium.interfaces.ShortHash.Lazy
cryptoShortHash -
Methods inherited from class com.goterl.lazysodium.interfaces.Auth.Native
cryptoAuthHMACSha256, cryptoAuthHMACSha256Final, cryptoAuthHMACSha256Init, cryptoAuthHMACSha256Update, cryptoAuthHMACSha256Verify, cryptoAuthHMACSha512, cryptoAuthHMACSha512256, cryptoAuthHMACSha512256Final, cryptoAuthHMACSha512256Init, cryptoAuthHMACSha512256Update, cryptoAuthHMACSha512256Verify, cryptoAuthHMACSha512Final, cryptoAuthHMACSha512Init, cryptoAuthHMACSha512Update, cryptoAuthHMACSha512Verify -
Methods inherited from class com.goterl.lazysodium.interfaces.Auth.Lazy
cryptoAuthHMACSha, cryptoAuthHMACShaFinal, cryptoAuthHMACShaFinal, cryptoAuthHMACShaFinal, cryptoAuthHMACShaInit, cryptoAuthHMACShaInit, cryptoAuthHMACShaInit, cryptoAuthHMACShaKeygen, cryptoAuthHMACShaUpdate, cryptoAuthHMACShaUpdate, cryptoAuthHMACShaUpdate, cryptoAuthHMACShaVerify -
Methods inherited from class com.goterl.lazysodium.interfaces.SecretStream.Native
cryptoSecretStreamInitPull, cryptoSecretStreamInitPush, cryptoSecretStreamPull, cryptoSecretStreamPull, cryptoSecretStreamPush, cryptoSecretStreamPush, cryptoSecretStreamPush, cryptoSecretStreamRekey -
Methods inherited from class com.goterl.lazysodium.interfaces.SecretStream.Lazy
cryptoSecretStreamPull, cryptoSecretStreamPush -
Methods inherited from class com.goterl.lazysodium.interfaces.Stream.Native
cryptoStreamChaCha20, cryptoStreamChaCha20Ietf, cryptoStreamChaCha20IetfXor, cryptoStreamChaCha20IetfXorIc, cryptoStreamChaCha20Xor, cryptoStreamChaCha20XorIc, cryptoStreamChacha20IetfXorIc, cryptoStreamChacha20XorIc, cryptoStreamSalsa20, cryptoStreamSalsa20Xor, cryptoStreamSalsa20XorIc, cryptoStreamXSalsa20, cryptoStreamXSalsa20Xor, cryptoStreamXSalsa20XorIc -
Methods inherited from class com.goterl.lazysodium.interfaces.Stream.Lazy
cryptoStream, cryptoStream, cryptoStreamKeygen, cryptoStreamXor, cryptoStreamXorDecrypt, cryptoStreamXorIc, cryptoStreamXorIcDecrypt -
Methods inherited from class com.goterl.lazysodium.interfaces.Padding.Native
sodiumUnpad -
Methods inherited from class com.goterl.lazysodium.interfaces.PwHash.Native
cryptoPwHash, cryptoPwHashStr -
Methods inherited from class com.goterl.lazysodium.interfaces.PwHash.Lazy
cryptoPwHash, cryptoPwHashStr, cryptoPwHashStrRemoveNulls, cryptoPwHashString -
Methods inherited from class com.goterl.lazysodium.interfaces.Hash.Native
cryptoHashSha256Update, cryptoHashSha512Update -
Methods inherited from class com.goterl.lazysodium.interfaces.Sign.Native
cryptoSign, cryptoSignDetached, cryptoSignEd25519SkToPk, cryptoSignOpen -
Methods inherited from class com.goterl.lazysodium.interfaces.Box.Native
cryptoBoxCurve25519XChaCha20Poly1305Detached, cryptoBoxCurve25519XChaCha20Poly1305DetachedAfterNm, cryptoBoxCurve25519XChaCha20Poly1305Easy, cryptoBoxCurve25519XChaCha20Poly1305EasyAfterNm, cryptoBoxCurve25519XChaCha20Poly1305OpenDetached, cryptoBoxCurve25519XChaCha20Poly1305OpenDetachedAfterNm, cryptoBoxCurve25519XChaCha20Poly1305OpenEasy, cryptoBoxCurve25519XChaCha20Poly1305OpenEasyAfterNm, cryptoBoxCurve25519XChaCha20Poly1305SealOpen, cryptoBoxDetached, cryptoBoxDetachedAfterNm, cryptoBoxEasy, cryptoBoxEasyAfterNm, cryptoBoxOpenDetached, cryptoBoxOpenDetachedAfterNm, cryptoBoxOpenEasy, cryptoBoxOpenEasyAfterNm, cryptoBoxSealOpen -
Methods inherited from class com.goterl.lazysodium.interfaces.Box.Lazy
cryptoBoxEasyAfterNm, cryptoBoxOpenDetachedAfterNm, cryptoBoxOpenEasyAfterNm -
Methods inherited from class com.goterl.lazysodium.interfaces.SecretBox.Native
cryptoSecretBoxDetached, cryptoSecretBoxEasy, cryptoSecretBoxOpenDetached, cryptoSecretBoxOpenEasy, cryptoSecretBoxXChaCha20Poly1305Detached, cryptoSecretBoxXChaCha20Poly1305Easy, cryptoSecretBoxXChaCha20Poly1305OpenDetached, cryptoSecretBoxXChaCha20Poly1305OpenEasy -
Methods inherited from class com.goterl.lazysodium.interfaces.KeyExchange.Native
cryptoKxClientSessionKeys, cryptoKxServerSessionKeys -
Methods inherited from class com.goterl.lazysodium.interfaces.KeyExchange.Lazy
cryptoKxClientSessionKeys, cryptoKxClientSessionKeys, cryptoKxClientSessionKeys, cryptoKxServerSessionKeys, cryptoKxServerSessionKeys, cryptoKxServerSessionKeys -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
LazySodium
LazySodium()
-
LazySodium
LazySodium(Charset charset)
-
LazySodium
LazySodium(MessageEncoder messageEncoder)
-
LazySodium
LazySodium(Charset charset, MessageEncoder messageEncoder)
-
-
Method Detail
-
sodiumInit
int sodiumInit()
-
sodiumBin2Hex
String sodiumBin2Hex(Array<byte> bin)
Binary to hexadecimal. This method does not null terminate strings.
- Parameters:
bin- The binary bytes you want to convert to a string.
-
sodiumHex2Bin
Array<byte> sodiumHex2Bin(String hex)
Hexadecimal to binary. Does not null terminate the binaryarray.
- Parameters:
hex- Hexadecimal string (a string that'smade up of the characters 0123456789ABCDEF)to convert to a binary array.
-
toHex
static String toHex(Array<byte> bin)
Bytes to hexadecimal. Equivalent to sodiumBin2Hex but static.
- Parameters:
bin- Byte array.
-
toBin
static Array<byte> toBin(String hex)
Hexadecimal string to bytes. Equivalent to sodiumHex2Bin} but static.
- Parameters:
hex- Hexadecimal string to convert to bytes.
-
randomBytesRandom
long randomBytesRandom()
Return a unsigned int byte 0 and 0xffffffff included.
-
randomBytesBuf
void randomBytesBuf(Array<byte> buff, int size)
Fill a buffer with random bytes.
- Parameters:
buff- Buffer to fill.size- The number of bytes in the array to fill with random bytes.
-
randomBytesBuf
Array<byte> randomBytesBuf(int size)
Get a random number of bytes.
- Parameters:
size- The length of the byte array to return.
-
nonce
Array<byte> nonce(int size)
Get a random number of bytes to use in a nonce.
- Parameters:
size- The size of the byte array to return.
-
randomBytesUniform
long randomBytesUniform(int upperBound)
Returns an unpredictable value between 0 and upperBound (excluded).Unlike randombytes_random() % upper_bound, it guarantees a uniform distributionof the possible output values even when upper_bound is not a power of 2. Notethat an upper_bound less than 2 leaves only a single element to be chosen, namely 0.
- Parameters:
upperBound- Upper bound (exclusive)
-
randomBytesDeterministic
void randomBytesDeterministic(Array<byte> buff, int size, Array<byte> seed)
Fill a buffer with deterministically random bytes given a seed.
- Parameters:
buff- Buffer to fillsize- The number of bytes in the array to fill with random bytes.seed- Seed to provide.
-
randomBytesDeterministic
Array<byte> randomBytesDeterministic(int size, Array<byte> seed)
Get deterministically random bytes given a seed.
- Parameters:
size- Size of byte array to return.seed- Seed to provide.
-
sodiumPad
boolean sodiumPad(IntByReference paddedBuffLen, Pointer buf, int unpaddedBufLen, int blockSize, int maxBufLen)
Adds extra padding to a buffer
{@code buf}whoseoriginal size is{@code unpaddedBufLen}in orderto extend its total length to a multiple of{@code blocksize}.- Parameters:
paddedBuffLen- New length of buffer.buf- The buffer byte array.unpaddedBufLen- The length of{@code buf}with no padding.blockSize- Block size.maxBufLen- The absolute maximum you want this buffer lengthto be.
-
sodiumUnpad
boolean sodiumUnpad(IntByReference unPaddedBuffLen, Pointer buf, int paddedBufLen, int blockSize)
Computes the original, unpadded length of a message previously padded using sodiumPad. The original length is put into
{@code unpaddedBufLen}.- Parameters:
buf- The buffer.paddedBufLen- The padded buffer size.blockSize- The block size.
-
sodiumMemZero
void sodiumMemZero(Array<byte> pnt, int len)
The sodium_memzero() function tries to effectively zero len bytes starting at pnt,even if optimizations are being applied to the code.
- Parameters:
pnt- The byte array to zero out.len- How many bytes to zero out.
-
sodiumMLock
boolean sodiumMLock(Array<byte> array, int len)
Locks at least len bytes of memory from the array.This can help avoid swapping sensitive data to disk.
- Parameters:
array- Array to lock.len- Number of bytes to lock.
-
sodiumMUnlock
boolean sodiumMUnlock(Array<byte> array, int len)
Unlocks at least len bytes of memory from the array.
- Parameters:
array- Array to unlock.len- Number of bytes to unlock.
-
sodiumMalloc
Pointer sodiumMalloc(int size)
Returns a pointer from which exactlysize contiguous bytes of memory can be accessed.
- Parameters:
size- The size of the byte array to allocate.
-
sodiumAllocArray
Pointer sodiumAllocArray(int count, int size)
Returns a pointer from whichcount objects that are size bytes of memory each can be accessed.It provides the same guarantees as sodiumMalloc butalso protects against arithmetic overflows when count * size exceeds SIZE_MAX.
- Parameters:
count- Number of objectssize- Size of those objects
-
sodiumFree
void sodiumFree(Pointer p)
Unlocks and deallocates memory allocated using sodiumMalloc or sodiumAllocArray}.
- Parameters:
p- The pointer to which an array shall be freed.
-
sodiumMProtectNoAccess
boolean sodiumMProtectNoAccess(Pointer ptr)
Makes a region allocated using sodiumMalloc or sodiumAllocArray}inaccessible. It cannot be read or written, but the data is preserved.
- Parameters:
ptr- The pointer to a region to decline access to.
-
sodiumMProtectReadOnly
boolean sodiumMProtectReadOnly(Pointer ptr)
Marks a region allocated using sodiumMalloc or sodiumAllocArray}as read-only.Attempting to modify the data will cause the process to terminate.
- Parameters:
ptr- Pointer to the region.
-
sodiumMProtectReadWrite
boolean sodiumMProtectReadWrite(Pointer ptr)
Marks a region allocated using sodiumMalloc or sodiumAllocArray}as readable and writable, after having been protected using sodiumMProtectReadOnly or sodiumMProtectNoAccess}/
- Parameters:
ptr- Pointer to the region.
-
cryptoKdfKeygen
void cryptoKdfKeygen(Array<byte> masterKey)
Creates a master key.
- Parameters:
masterKey- The byte array to populate.
-
cryptoKdfDeriveFromKey
boolean cryptoKdfDeriveFromKey(Array<byte> subKey, int subKeyLen, long subKeyId, Array<byte> context, Array<byte> masterKey)
Derive a subkey from a master key.
- Parameters:
subKey- The subkey.subKeyLen- The length of the subkey.subKeyId- ID of subkey.context- The context of the subkey.masterKey- The generated master key from cryptoKdfKeygen.
-
cryptoKdfKeygen
Key cryptoKdfKeygen()
Auto generates a master key and returnsit in string format.The reason why this does not return a string via the normal 'masterKey.getBytes()'is because the resulting string is mangled.
-
cryptoKdfDeriveFromKey
Key cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey)
Derive a subkey from a master key.
- Parameters:
lengthOfSubKey- The length of the subkey.subKeyId- The ID of the subkey.context- The context of the subkey.masterKey- The generated master key from cryptoKdfKeygen.
-
cryptoKxKeypair
boolean cryptoKxKeypair(Array<byte> publicKey, Array<byte> secretKey)
Generate a public and a secret key.
- Parameters:
publicKey- Public key will be populated here of size PUBLICKEYBYTES.secretKey- Secret key will be populated here of size SECRETKEYBYTES.
-
cryptoKxSeedKeypair
boolean cryptoKxSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)
Deterministically generate a public and secret key.Store the seed somewhere if you want to generate thesekeys again.
- Parameters:
publicKey- Public key will be populated here of size PUBLICKEYBYTES.secretKey- Secret key will be populated here of size SECRETKEYBYTES.seed- A random seed of size SEEDBYTES.
-
cryptoKxClientSessionKeys
boolean cryptoKxClientSessionKeys(Array<byte> rx, Array<byte> tx, Array<byte> clientPk, Array<byte> clientSk, Array<byte> serverPk)
This function computes a pair of shared keys(rx and tx) using the client's public key clientPk,the client's secret key clientSk and the server's public key serverPk.
- Parameters:
rx- Shared key 1 of size SESSIONKEYBYTES.tx- Shared key 2 of size SESSIONKEYBYTES.clientPk- Client public key of size PUBLICKEYBYTES.clientSk- Client secret key of size SECRETKEYBYTES.serverPk- Server public key of size PUBLICKEYBYTES.
-
cryptoKxServerSessionKeys
boolean cryptoKxServerSessionKeys(Array<byte> rx, Array<byte> tx, Array<byte> serverPk, Array<byte> serverSk, Array<byte> clientPk)
This function computes a pair of shared keys(rx and tx) using the client's public key clientPk,the server's secret key serverSk and the server's public key serverPk.
- Parameters:
rx- Shared key 1 of size SESSIONKEYBYTES.tx- Shared key 2 of size SESSIONKEYBYTES.serverPk- Server public key of size PUBLICKEYBYTES.serverSk- Server secret key of size SECRETKEYBYTES.clientPk- Client public key of size PUBLICKEYBYTES.
-
cryptoKxKeypair
KeyPair cryptoKxKeypair()
Generate a public and secret key.
-
cryptoKxKeypair
KeyPair cryptoKxKeypair(Array<byte> seed)
Deterministically generate a public and secret key.Store the seed somewhere if you want to generate thesekeys again.
- Parameters:
seed- A random seed of size SEEDBYTES.
-
cryptoKxClientSessionKeys
@Deprecated(forRemoval = true, since = 6.0.0) SessionPair cryptoKxClientSessionKeys(KeyPair clientKeyPair, KeyPair serverKeyPair)
Generate a client's session keys. This shouldbe performed on the client.
- Parameters:
clientKeyPair- Provide the client's public and private key.serverKeyPair- Provide the server's public key only.
-
cryptoKxClientSessionKeys
SessionPair cryptoKxClientSessionKeys(KeyPair clientKeyPair, Key serverPublicKey)
Generate a client's session keys. This shouldbe performed on the client.
- Parameters:
clientKeyPair- Provide the client's public and private key.serverPublicKey- Provide the server's public key.
-
cryptoKxServerSessionKeys
SessionPair cryptoKxServerSessionKeys(Key serverPk, Key serverSk, Key clientPk)
Computes a pair of shared keys (server-side)(rx and tx) using the client's public key clientPk,the server's secret key serverSk and the server's public key serverPk.
- Parameters:
serverPk- Server public key of size PUBLICKEYBYTES.serverSk- Server secret key of size SECRETKEYBYTES.clientPk- Client public key of size PUBLICKEYBYTES.
-
cryptoKxClientSessionKeys
SessionPair cryptoKxClientSessionKeys(Key clientPk, Key clientSk, Key serverPk)
Generate a client's session keys. This shouldbe performed on the client.
- Parameters:
clientPk- Client public key of size PUBLICKEYBYTES.clientSk- Client secret key of size SECRETKEYBYTES.serverPk- Server public key of size PUBLICKEYBYTES.
-
cryptoKxServerSessionKeys
@Deprecated(forRemoval = true, since = 6.0.0) SessionPair cryptoKxServerSessionKeys(KeyPair serverKeyPair, KeyPair clientKeyPair)
Generate a server's session keys. This shouldbe performed on the server.
- Parameters:
serverKeyPair- Provide the server's public and private key.clientKeyPair- Provide the client's public key only.
-
cryptoKxServerSessionKeys
SessionPair cryptoKxServerSessionKeys(KeyPair serverKeyPair, Key clientPublicKey)
Generate a server's session keys. This shouldbe performed on the server.
- Parameters:
serverKeyPair- Provide the server's public and private key.clientPublicKey- Provide the client's public key.
-
cryptoPwHash
boolean cryptoPwHash(Array<byte> outputHash, int outputHashLen, Array<byte> password, int passwordLen, Array<byte> salt, long opsLimit, NativeLong memLimit, PwHash.Alg alg)
Based on a password you provide, hash thatpassword and put the output into
{@code outputHash}.Take note that the output of this does NOT output a traditionalArgon 2 string as the underlying native implementation calls argon2id_hash_rawinstead of argon2id_hash_encoded. If you want an Argon 2 encoded string please referto cryptoPwHashStr instead.- Parameters:
outputHash- Where to store the resulting password hash.outputHashLen- The password hash's length.password- The password that you want to hash.passwordLen- The length of the password's bytes.salt- A salt that's randomly generated.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.alg- The algorithm to use.
-
cryptoPwHashStr
boolean cryptoPwHashStr(Array<byte> outputStr, Array<byte> password, int passwordLen, long opsLimit, NativeLong memLimit)
Hashes a password and stores it into an array. The output isan ASCII encoded string in a byte array.
- Parameters:
outputStr- An array to hold the hash.password- A password that you want to hash.passwordLen- The password's byte length.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.
-
cryptoPwHashStrVerify
boolean cryptoPwHashStrVerify(Array<byte> hash, Array<byte> password, int passwordLen)
Verifies a hashed password. Remember: you must adda null byte to the end of the hash so that this works properly!
- Parameters:
hash- The hash of the password.password- The password to check if it equals the hash's password.passwordLen- The checking password's length.
-
cryptoPwHashStrNeedsRehash
PwHash.NeedsRehashResult cryptoPwHashStrNeedsRehash(Array<byte> hash, long opsLimit, NativeLong memLimit)
Checks whether the hash needs a rehash.
- Parameters:
hash- The hash.opsLimit- The operations limit used.memLimit- The memory limit used.
-
cryptoPwHash
String cryptoPwHash(String password, int lengthOfHash, Array<byte> salt, long opsLimit, NativeLong memLimit, PwHash.Alg alg)
Hashes a given password.
- Parameters:
password- The password to hash.salt- A salt to use with the hash, generated randomly.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.alg- The algorithm to use.
-
cryptoPwHashString
String cryptoPwHashString(String password, long opsLimit, NativeLong memLimit)
The most minimal way of hashing a given password to a standard-format string including all used parameters.We auto-generate the salt and use the default hashing algorithm PwHash.Alg.
- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.
-
cryptoPwHashStr
@Deprecated() String cryptoPwHashStr(String password, long opsLimit, NativeLong memLimit)
The most minimal way of hashing a given password to a string including all used parameters.We auto-generate the salt and use the default hashing algorithm PwHash.Alg.
- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.
-
cryptoPwHashStrRemoveNulls
@Deprecated() String cryptoPwHashStrRemoveNulls(String password, long opsLimit, NativeLong memLimit)
Hashes a string to a string representation including the used parameters, and removes alluseless null bytes. Uses the hashing algorithm PwHash.Alg.
- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing.memLimit- The amount of memory to use.
-
cryptoPwHashStringVerify
boolean cryptoPwHashStringVerify(String hash, String password)
Verifies a password represented as a standard-formatted hash, generated by cryptoPwHashString.
- Parameters:
hash- Standard-formatted hashpassword- The password.
-
cryptoPwHashStrVerify
@Deprecated() boolean cryptoPwHashStrVerify(String hash, String password)
Verifies a password represented as a long encoded string generated by cryptoPwHashStr or cryptoPwHashStrRemoveNulls.
- Parameters:
hash- The encoded hash generated by cryptoPwHashStr or cryptoPwHashStrRemoveNullspassword- The password.
-
cryptoPwHashStringNeedsRehash
PwHash.NeedsRehashResult cryptoPwHashStringNeedsRehash(String hash, long opsLimit, NativeLong memLimit)
Checks whether the hash needs a rehash.
- Parameters:
hash- Standard-formatted hash generated by cryptoPwHashString.opsLimit- The operations limit which should be used.memLimit- The memory limit which should be used.
-
cryptoHashSha256
boolean cryptoHashSha256(Array<byte> out, Array<byte> in, int inLen)
-
cryptoHashSha256Init
boolean cryptoHashSha256Init(Hash.State256 state)
-
cryptoHashSha256Update
boolean cryptoHashSha256Update(Hash.State256 state, Array<byte> in, int inLen)
-
cryptoHashSha256Final
boolean cryptoHashSha256Final(Hash.State256 state, Array<byte> out)
-
cryptoHashSha512
boolean cryptoHashSha512(Array<byte> out, Array<byte> in, int inLen)
-
cryptoHashSha512Init
boolean cryptoHashSha512Init(Hash.State512 state)
-
cryptoHashSha512Update
boolean cryptoHashSha512Update(Hash.State512 state, Array<byte> in, int inLen)
-
cryptoHashSha512Final
boolean cryptoHashSha512Final(Hash.State512 state, Array<byte> out)
-
cryptoHashSha256
String cryptoHashSha256(String message)
-
cryptoHashSha512
String cryptoHashSha512(String message)
-
cryptoHashSha256Update
boolean cryptoHashSha256Update(Hash.State256 state, String messagePart)
-
cryptoHashSha256Final
String cryptoHashSha256Final(Hash.State256 state)
-
cryptoHashSha512Update
boolean cryptoHashSha512Update(Hash.State512 state, String messagePart)
-
cryptoHashSha512Final
String cryptoHashSha512Final(Hash.State512 state)
-
cryptoSecretBoxKeygen
void cryptoSecretBoxKeygen(Array<byte> key)
Creates a random key. It is equivalent to calling randomBytesBuf but improves codeclarity and can prevent misuse by ensuringthat the provided key length isalways correct.
- Parameters:
key- The key which is of size KEYBYTES.
-
cryptoSecretBoxEasy
boolean cryptoSecretBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message using a key generated by cryptoSecretBoxKeygen.
- Parameters:
cipherText- The cipher text.message- The message to encrypt.messageLen- The message byte array length.nonce- A nonce of size NONCEBYTES generated by randomBytesBuf.key- The symmetric key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxOpenEasy
boolean cryptoSecretBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts and verifies a message using a key generatedby cryptoSecretBoxKeygen.
- Parameters:
message- The message will be put into here once decrypted.cipherText- The cipher produced by cryptoSecretBoxEasy.cipherTextLen- The cipher text length.nonce- This has to be the same nonce that was used whenencrypting using{@code cryptoSecretBoxEasy}.key- The key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxDetached
boolean cryptoSecretBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message. Alongside the cipher a mac isreturned which can be stored in separate locations.
- Parameters:
cipherText- The encrypted message of length{@code messageLen}.mac- The mac.message- The message to encrypt.messageLen- The message's length.nonce- A randomly generated nonce of size NONCEBYTES.key- The key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxOpenDetached
boolean cryptoSecretBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts a message with the mac and the cipher providedseparately.
- Parameters:
message- The message length which is the same size as{@code cipherTextLen}.cipherText- The cipher.mac- The mac.cipherTextLen- The cipher text length.nonce- The nonce that was used in cryptoSecretBoxDetached.key- The key generated by cryptoSecretBoxKeygen.
-
cryptoSecretBoxXChaCha20Poly1305Keygen
void cryptoSecretBoxXChaCha20Poly1305Keygen(Array<byte> key)
Creates a random key for the XChaCha20Poly1305 variant. It is equivalent to calling randomBytesBuf but improves codeclarity and can prevent misuse by ensuringthat the provided key length isalways correct.
- Parameters:
key- The key which is of size XCHACHA20POLY1305_KEYBYTES.
-
cryptoSecretBoxXChaCha20Poly1305Easy
boolean cryptoSecretBoxXChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message by the XChaCha20Poly1305 variant using a key generated by cryptoSecretBoxKeygen.
- Parameters:
cipherText- The cipher text.message- The message to encrypt.messageLen- The message byte array length.nonce- A nonce of size XCHACHA20POLY1305_NONCEBYTES generated by randomBytesBuf.key- The symmetric key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305OpenEasy
boolean cryptoSecretBoxXChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts and verifies a message using a key generatedby cryptoSecretBoxXChaCha20Poly1305Keygen.
- Parameters:
message- The message will be put into here once decrypted.cipherText- The cipher produced by cryptoSecretBoxXChaCha20Poly1305Easy.cipherTextLen- The cipher text length.nonce- This has to be the same nonce that was used whenencrypting using{@code cryptoSecretBoxXChaCha20Poly1305Easy}.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305Detached
boolean cryptoSecretBoxXChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
Encrypts a message using the XChaCha20Poly1305 variant. Alongside the cipher a mac isreturned which can be stored in separate locations.
- Parameters:
cipherText- The encrypted message of length{@code messageLen}.mac- The mac.message- The message to encrypt.messageLen- The message's length.nonce- A randomly generated nonce of size XCHACHA20POLY1305_NONCEBYTES.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxXChaCha20Poly1305OpenDetached
boolean cryptoSecretBoxXChaCha20Poly1305OpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)
Decrypts a message with the mac and the cipher providedseparately, using the XChaCha20Poly1305 variant.
- Parameters:
message- The message length which is the same size as{@code cipherTextLen}.cipherText- The cipher.mac- The mac.cipherTextLen- The cipher text length.nonce- The nonce that was used in cryptoSecretBoxXChaCha20Poly1305Detached.key- The key generated by cryptoSecretBoxXChaCha20Poly1305Keygen.
-
cryptoSecretBoxKeygen
Key cryptoSecretBoxKeygen()
Generates a secret symmetric key.
-
cryptoSecretBoxEasy
String cryptoSecretBoxEasy(String message, Array<byte> nonce, Key key)
Encrypts a message.
- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of size NONCEBYTES.key- The key.
-
cryptoSecretBoxOpenEasy
String cryptoSecretBoxOpenEasy(String cipher, Array<byte> nonce, Key key)
Decrypts a message.
- Parameters:
cipher- The hexadecimal cipher text.nonce- The nonce that was used when you encrypted with cryptoSecretBoxEasy.key- The key.
-
cryptoSecretBoxDetached
DetachedEncrypt cryptoSecretBoxDetached(String message, Array<byte> nonce, Key key)
Encrypts a message with the mac separately
- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce of size NONCEBYTES.key- The key.
-
cryptoSecretBoxOpenDetached
String cryptoSecretBoxOpenDetached(DetachedEncrypt cipherAndMac, Array<byte> nonce, Key key)
Decrypts a message.
- Parameters:
cipherAndMac- The hexadecimal cipher text.nonce- The nonce that was used when you encrypted with cryptoSecretBoxEasy.key- The key.
-
cryptoScalarMultBase
boolean cryptoScalarMultBase(Array<byte> publicKey, Array<byte> secretKey)
-
cryptoScalarMultBase
Key cryptoScalarMultBase(Key secretKey)
Generate a public key from a private key.
- Parameters:
secretKey- Provide the secret key.
-
cryptoScalarMult
boolean cryptoScalarMult(Array<byte> shared, Array<byte> secretKey, Array<byte> publicKey)
-
cryptoScalarMult
Key cryptoScalarMult(Key secretKey, Key publicKey)
Generate a shared key from another user's public keyand a secret key.
- Parameters:
secretKey- A secret key.publicKey- Another user's public key.
-
cryptoBoxKeypair
boolean cryptoBoxKeypair(Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxSeedKeypair
boolean cryptoBoxSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)
-
cryptoBoxEasy
boolean cryptoBoxEasy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxOpenEasy
boolean cryptoBoxOpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxDetached
boolean cryptoBoxDetached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxOpenDetached
boolean cryptoBoxOpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxBeforeNm
boolean cryptoBoxBeforeNm(Array<byte> k, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxEasyAfterNm
boolean cryptoBoxEasyAfterNm(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxOpenEasyAfterNm
boolean cryptoBoxOpenEasyAfterNm(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxDetachedAfterNm
boolean cryptoBoxDetachedAfterNm(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxOpenDetachedAfterNm
boolean cryptoBoxOpenDetachedAfterNm(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxSeal
boolean cryptoBoxSeal(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> publicKey)
-
cryptoBoxSealOpen
boolean cryptoBoxSealOpen(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305Keypair
boolean cryptoBoxCurve25519XChaCha20Poly1305Keypair(Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305SeedKeypair
boolean cryptoBoxCurve25519XChaCha20Poly1305SeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)
-
cryptoBoxCurve25519XChaCha20Poly1305Easy
boolean cryptoBoxCurve25519XChaCha20Poly1305Easy(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305OpenEasy
boolean cryptoBoxCurve25519XChaCha20Poly1305OpenEasy(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305Detached
boolean cryptoBoxCurve25519XChaCha20Poly1305Detached(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305OpenDetached
boolean cryptoBoxCurve25519XChaCha20Poly1305OpenDetached(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305BeforeNm
boolean cryptoBoxCurve25519XChaCha20Poly1305BeforeNm(Array<byte> k, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxCurve25519XChaCha20Poly1305EasyAfterNm
boolean cryptoBoxCurve25519XChaCha20Poly1305EasyAfterNm(Array<byte> cipherText, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxCurve25519XChaCha20Poly1305OpenEasyAfterNm
boolean cryptoBoxCurve25519XChaCha20Poly1305OpenEasyAfterNm(Array<byte> message, Array<byte> cipherText, int cipherTextLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxCurve25519XChaCha20Poly1305DetachedAfterNm
boolean cryptoBoxCurve25519XChaCha20Poly1305DetachedAfterNm(Array<byte> cipherText, Array<byte> mac, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxCurve25519XChaCha20Poly1305OpenDetachedAfterNm
boolean cryptoBoxCurve25519XChaCha20Poly1305OpenDetachedAfterNm(Array<byte> message, Array<byte> cipherText, Array<byte> mac, int cipherTextLen, Array<byte> nonce, Array<byte> key)
-
cryptoBoxCurve25519XChaCha20Poly1305Seal
boolean cryptoBoxCurve25519XChaCha20Poly1305Seal(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> publicKey)
-
cryptoBoxCurve25519XChaCha20Poly1305SealOpen
boolean cryptoBoxCurve25519XChaCha20Poly1305SealOpen(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> publicKey, Array<byte> secretKey)
-
cryptoBoxKeypair
KeyPair cryptoBoxKeypair()
Generate a secret and public key.
-
cryptoBoxSeedKeypair
KeyPair cryptoBoxSeedKeypair(Array<byte> seed)
Generate a public and secret key deterministically.
- Parameters:
seed- The seed to generate the key.
-
cryptoBoxEasy
String cryptoBoxEasy(String message, Array<byte> nonce, KeyPair keyPair)
Encrypts a message.
- Parameters:
message- The message.nonce- The nonce of size NONCEBYTES.keyPair- A keypair.
-
cryptoBoxOpenEasy
String cryptoBoxOpenEasy(String cipherText, Array<byte> nonce, KeyPair keyPair)
Decrypts a previously encrypted message.
- Parameters:
cipherText- Encrypted via cryptoBoxEasy and then sodiumBin2Hex'ified.nonce- The nonce of size NONCEBYTES.keyPair- A keypair.
-
cryptoBoxBeforeNm
String cryptoBoxBeforeNm(Array<byte> publicKey, Array<byte> secretKey)
If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations.
- Parameters:
publicKey- A public key as generated by cryptoBoxKeypair.secretKey- A secret key as generated by cryptoBoxKeypair.
-
cryptoBoxBeforeNm
String cryptoBoxBeforeNm(KeyPair keyPair)
If you send several messages to the same receiver or receive several messages from thesame sender, you can gain speed by calculatingthe shared key only once, and reusing it in subsequent operations.
- Parameters:
keyPair- A public and secret key as generated by cryptoBoxKeypair.
-
cryptoBoxEasyAfterNm
String cryptoBoxEasyAfterNm(String message, Array<byte> nonce, String sharedSecretKey)
Encrypt a message.
- Parameters:
message- The message for encryption.nonce- A randomly generated nonce via nonce}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxOpenEasyAfterNm
String cryptoBoxOpenEasyAfterNm(String cipher, Array<byte> nonce, String sharedSecretKey)
Decrypt a message.
- Parameters:
cipher- The cipher text to be decrypted.nonce- The same nonce used to encrypt the{@code cipher}- cryptoBoxEasyAfterNm.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxDetachedAfterNm
DetachedEncrypt cryptoBoxDetachedAfterNm(String message, Array<byte> nonce, String sharedSecretKey)
Encrypt a message but allow for storage ofthe mac separately.
- Parameters:
message- The message to encrypt.nonce- A randomly generated nonce via nonce}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxOpenDetachedAfterNm
DetachedDecrypt cryptoBoxOpenDetachedAfterNm(DetachedEncrypt detachedEncrypt, Array<byte> nonce, String sharedSecretKey)
Decrypt a message.
- Parameters:
detachedEncrypt- The cipher and mac used to decrypted the message.nonce- The same nonce used to encrypt - cryptoBoxDetachedAfterNm}.sharedSecretKey- The shared secret key as generated via cryptoBoxBeforeNm.
-
cryptoBoxSealEasy
String cryptoBoxSealEasy(String message, Key publicKey)
Encrypts a message.
- Parameters:
message- The message.publicKey- A public key.
-
cryptoBoxSealOpenEasy
String cryptoBoxSealOpenEasy(String cipherText, KeyPair keyPair)
Decrypts a previously encrypted message.
- Parameters:
cipherText- Encrypted via cryptoBoxSealEasy and then sodiumBin2Hex'ified.keyPair- A keypair.
-
cryptoSignInit
boolean cryptoSignInit(Sign.StateCryptoSign state)
Useful for signing a multi-part message (Ed25519ph).If the message can fit in memory and can be supplied as asingle chunk, the single-part API should be preferred.This function must be called before the first crypto_sign_update() call.
- Parameters:
state- The state.
-
cryptoSignUpdate
boolean cryptoSignUpdate(Sign.StateCryptoSign state, Array<byte> chunk, int chunkLength)
Add a new chunk of length chunkLen bytes to themessage that will eventually be signed.
- Parameters:
state- The state.chunk- A part of the long message.chunkLength- Message length.
-
cryptoSignFinalCreate
boolean cryptoSignFinalCreate(Sign.StateCryptoSign state, Array<byte> sig, Array<byte> sk)
This function computes a signature for the previously supplied message,using the secret key sk and puts it into sig.
- Parameters:
state- The state.sig- Resultant signature.sk- Secret key.
-
cryptoSignFinalVerify
boolean cryptoSignFinalVerify(Sign.StateCryptoSign state, Array<byte> sig, Array<byte> pk)
Verifies that sig is a valid signature for the message whosecontent has been previously supplied using crypto_update(),using the public key pk.
- Parameters:
state- The state.sig- Resultant signature.pk- Secret key.
-
cryptoSignKeypair
boolean cryptoSignKeypair(Array<byte> publicKey, Array<byte> secretKey)
Generate a signing keypair (ed25519).
- Parameters:
publicKey- Public key.secretKey- Secret key.
-
cryptoSignSeedKeypair
boolean cryptoSignSeedKeypair(Array<byte> publicKey, Array<byte> secretKey, Array<byte> seed)
Deterministically generate a public and secret key.
- Parameters:
publicKey- Public key.secretKey- Secret key.seed- The seed used to generate the keys.
-
cryptoSign
boolean cryptoSign(Array<byte> signedMessage, Array<byte> message, int messageLen, Array<byte> secretKey)
Sign a message.
- Parameters:
signedMessage- Signed message will be placed here.message- The message.messageLen- The message length.secretKey- The secret key.
-
cryptoSignOpen
boolean cryptoSignOpen(Array<byte> message, Array<byte> signedMessage, int signedMessageLen, Array<byte> publicKey)
Verify a signed message.
- Parameters:
message- The message will be placed in here.signedMessage- The signed message.signedMessageLen- The signed message length.publicKey- Public key.
-
cryptoSignDetached
boolean cryptoSignDetached(Array<byte> signature, Array<byte> message, int messageLen, Array<byte> secretKey)
Returns a signature for a message. Thisdoes not prepend the signature to the message.See cryptoSign for that.
- Parameters:
signature- The signature will be added to this byte array.message- The message to sign.messageLen- The message length.secretKey- The secret key.
-
cryptoSignVerifyDetached
boolean cryptoSignVerifyDetached(Array<byte> signature, Array<byte> message, int messageLen, Array<byte> publicKey)
Verifies that
{@code signature}is valid for the{@code message}.- Parameters:
signature- The signature.message- The message.messageLen- The message length.publicKey- The public key that signed the message.
-
convertPublicKeyEd25519ToCurve25519
boolean convertPublicKeyEd25519ToCurve25519(Array<byte> curve, Array<byte> ed)
Converts a public ed25519 key to a public curve25519 key.
- Parameters:
curve- The array in which the generated key will be placed.ed- The public key in ed25519.
-
convertSecretKeyEd25519ToCurve25519
boolean convertSecretKeyEd25519ToCurve25519(Array<byte> curve, Array<byte> ed)
Converts a secret ed25519 key to a secret curve25519 key.
- Parameters:
curve- The array in which the generated key will be placed.ed- The secret key in ed25519.
-
cryptoSignEd25519SkToSeed
boolean cryptoSignEd25519SkToSeed(Array<byte> seed, Array<byte> ed)
Extracts the seed value from a secret ed25519 key.
- Parameters:
seed- The array in which the seed value will be placed.ed- The secret key in ed25519.
-
cryptoSignEd25519SkToPk
boolean cryptoSignEd25519SkToPk(Array<byte> publicKey, Array<byte> secretKey)
Extracts the ed25519 public key from a secret ed25519 key.
- Parameters:
publicKey- The array in which the public key will be placed.
-
cryptoSignKeypair
KeyPair cryptoSignKeypair()
Generate a signing keypair (ed25519).
-
cryptoSignSeedKeypair
KeyPair cryptoSignSeedKeypair(Array<byte> seed)
Generate a signing keypair deterministically.
- Parameters:
seed- The seed to generate keys.
-
cryptoSignSecretKeyPair
KeyPair cryptoSignSecretKeyPair(Key secretKey)
Generate a signing keypair (ed25519), given a secret ed25519 key.
- Parameters:
secretKey- The ed25519 secret key.
-
cryptoSign
String cryptoSign(String message, String secretKey)
Sign a message.
- Parameters:
message- The message to sign.secretKey- The secret key.
-
cryptoSign
String cryptoSign(String message, Key secretKey)
Sign a message.
- Parameters:
message- The message to sign.secretKey- The secret key.
-
cryptoSignOpen
String cryptoSignOpen(String signedMessage, Key publicKey)
Checks that a message is validly signed by a public key.
- Parameters:
signedMessage- The signed message.publicKey- The public key that signed the message.
-
cryptoSignDetached
String cryptoSignDetached(String message, Key secretKey)
Returns a signature for a message. Thisdoes not prepend the signature to the message.See cryptoSign for that.
- Parameters:
message- The message to sign.secretKey- The secret key.
-
cryptoSignVerifyDetached
boolean cryptoSignVerifyDetached(String signature, String message, Key publicKey)
Verifies that
{@code signature}is valid for the{@code message}.- Parameters:
signature- The signature.message- The message.publicKey- The public key that signed the message.
-
convertKeyPairEd25519ToCurve25519
KeyPair convertKeyPairEd25519ToCurve25519(KeyPair ed25519KeyPair)
Converts a ed25519 keypair to a curve25519 keypair.
- Parameters:
ed25519KeyPair- The key pair.
-
cryptoSignEd25519SkToSeed
Array<byte> cryptoSignEd25519SkToSeed(Key secretKey)
Extracts the seed from an ed25519 secret key
- Parameters:
secretKey- The secret key
-
cryptoSecretStreamKeygen
void cryptoSecretStreamKeygen(Array<byte> key)
Generate a secret stream key.
- Parameters:
key- The key of size KEYBYTES.
-
cryptoSecretStreamInitPush
boolean cryptoSecretStreamInitPush(SecretStream.State state, Array<byte> header, Array<byte> key)
Initialises encryption with a state and a key.
- Parameters:
state- State to be used in other{@code cryptoSecretStreamPush()}functions.header- The header of size HEADERBYTES.key- The key as generated by cryptoSecretStreamKeygen.
-
cryptoSecretStreamPush
boolean cryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, byte tag)
Encrypt a
{@code message}. This is like cryptoSecretStreamPushbut without additional data.- Parameters:
state- State.cipher- The resulting cipher of size ABYTES +{@code messageLen}.cipherLen- The length of the resulting cipher will be stored here if not null.message- The message to encrypt.messageLen- The message length.tag- The tag.
-
cryptoSecretStreamPush
boolean cryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<byte> message, int messageLen, byte tag)
Encrypt a
{@code message}. This is like cryptoSecretStreamPushbut without additional data or an address to store the cipher.- Parameters:
state- State as initialised in cryptoSecretStreamInitPush.cipher- The resulting cipher of size ABYTES +{@code messageLen}.message- The message to encrypt.messageLen- The message length.tag- The tag.
-
cryptoSecretStreamPush
boolean cryptoSecretStreamPush(SecretStream.State state, Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, byte tag)
Encrypt a
{@code message}.- Parameters:
state- State as initialised in cryptoSecretStreamInitPush.cipher- The resulting cipher of size ABYTES +{@code messageLen}.cipherLen- The length of the resulting cipher will be stored here if not null.message- The message to encrypt.messageLen- The message length.additionalData- Additional data.additionalDataLen- Additional data length.tag- The tag.
-
cryptoSecretStreamInitPull
boolean cryptoSecretStreamInitPull(SecretStream.State state, Array<byte> header, Array<byte> key)
Initialises decryption using a state and a key.
- Parameters:
state- State to be used in other{@code cryptoSecretStreamPush()}functions.header- The header of size HEADERBYTES.key- The key as generated by cryptoSecretStreamKeygen.
-
cryptoSecretStreamPull
boolean cryptoSecretStreamPull(SecretStream.State state, Array<byte> message, Array<long> messageLen, Array<byte> tag, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen)
Decrypt a message.
- Parameters:
state- The state as put into cryptoSecretStreamInitPull.message- The message of size{@code cipherLen}- ABYTES.messageLen- The length of the resulting message will be stored here if not null.tag- The received tag will be stored here if not null.cipher- The resulting encrypted message.cipherLen- The cipher length.additionalData- Any authenticated data.additionalDataLen- Authenticated data length.
-
cryptoSecretStreamPull
boolean cryptoSecretStreamPull(SecretStream.State state, Array<byte> message, Array<byte> tag, Array<byte> cipher, int cipherLen)
Decrypt a message without additional data.
- Parameters:
state- The state as put into cryptoSecretStreamInitPull.message- The message of size{@code cipherLen}- ABYTES.tag- The received tag will be stored here if not null.cipher- The resulting encrypted message.cipherLen- The cipher length.
-
cryptoSecretStreamKeygen
Key cryptoSecretStreamKeygen()
Generates a key.
-
cryptoSecretStreamInitPush
SecretStream.State cryptoSecretStreamInitPush(Array<byte> header, Key key)
Initialise encryption.
- Parameters:
header- Header to supply.key- The key as generated by cryptoSecretStreamKeygen.
-
cryptoSecretStreamPush
String cryptoSecretStreamPush(SecretStream.State state, String message, byte tag)
Encrypt a
{@code message}.- Parameters:
state- State as initialised in cryptoSecretStreamInitPush.message- The message to encrypt.tag- The tag.
-
cryptoSecretStreamInitPull
SecretStream.State cryptoSecretStreamInitPull(Array<byte> header, Key key)
Initialises decryption using a state and a key.
- Parameters:
header- The header of size HEADERBYTES.key- The key as generated by cryptoSecretStreamKeygen}.
-
cryptoSecretStreamPull
String cryptoSecretStreamPull(SecretStream.State state, String cipher, Array<byte> tag)
Decrypt a message without additional data.
- Parameters:
state- The state as generated by cryptoSecretStreamInitPull.cipher- The resulting encrypted message.tag- The tag.
-
cryptoSecretStreamRekey
void cryptoSecretStreamRekey(SecretStream.State state)
Explicitly rekeys.
- Parameters:
state- The state to update.
-
cryptoStreamChaCha20Keygen
void cryptoStreamChaCha20Keygen(Array<byte> key)
-
cryptoStreamChaCha20
boolean cryptoStreamChaCha20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamChaCha20Xor
boolean cryptoStreamChaCha20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamChaCha20XorIc
boolean cryptoStreamChaCha20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
-
cryptoStreamChacha20XorIc
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoStreamChacha20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
Backward-compatible method name.
-
cryptoStreamChaCha20IetfKeygen
void cryptoStreamChaCha20IetfKeygen(Array<byte> key)
-
cryptoStreamChaCha20Ietf
boolean cryptoStreamChaCha20Ietf(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamChaCha20IetfXor
boolean cryptoStreamChaCha20IetfXor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamChaCha20IetfXorIc
boolean cryptoStreamChaCha20IetfXorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
-
cryptoStreamChacha20IetfXorIc
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoStreamChacha20IetfXorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
Backward-compatible method name.
-
cryptoStreamSalsa20Keygen
void cryptoStreamSalsa20Keygen(Array<byte> key)
-
cryptoStreamSalsa20
boolean cryptoStreamSalsa20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamSalsa20Xor
boolean cryptoStreamSalsa20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamSalsa20XorIc
boolean cryptoStreamSalsa20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
-
cryptoStreamXSalsa20Keygen
void cryptoStreamXSalsa20Keygen(Array<byte> key)
-
cryptoStreamXSalsa20
boolean cryptoStreamXSalsa20(Array<byte> c, int cLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamXSalsa20Xor
boolean cryptoStreamXSalsa20Xor(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, Array<byte> key)
-
cryptoStreamXSalsa20XorIc
boolean cryptoStreamXSalsa20XorIc(Array<byte> cipher, Array<byte> message, int messageLen, Array<byte> nonce, long ic, Array<byte> key)
-
cryptoStreamKeygen
Key cryptoStreamKeygen(Stream.Method method)
-
cryptoStream
@Deprecated(forRemoval = true, since = 6.0.0) Array<byte> cryptoStream(Array<byte> nonce, Key key, Stream.Method method)
Generate 20 bytes of keystream
- Parameters:
nonce- Noncekey- Keymethod- Stream cipher to use
-
cryptoStream
Array<byte> cryptoStream(int bytes, Array<byte> nonce, Key key, Stream.Method method)
-
cryptoStreamXor
String cryptoStreamXor(String message, Array<byte> nonce, Key key, Stream.Method method)
-
cryptoStreamXorDecrypt
String cryptoStreamXorDecrypt(String cipher, Array<byte> nonce, Key key, Stream.Method method)
-
cryptoStreamXorIc
String cryptoStreamXorIc(String message, Array<byte> nonce, long ic, Key key, Stream.Method method)
-
cryptoStreamXorIcDecrypt
String cryptoStreamXorIcDecrypt(String cipher, Array<byte> nonce, long ic, Key key, Stream.Method method)
-
cryptoAuth
boolean cryptoAuth(Array<byte> tag, Array<byte> in, int inLen, Array<byte> key)
Computes a tag for the message in, whose length is inLen bytes, and the key k.
- Parameters:
tag- Tag of size BYTES.in- A message.inLen- Message size.key- The key as generated by cryptoAuthKeygen.
-
cryptoAuthVerify
boolean cryptoAuthVerify(Array<byte> tag, Array<byte> in, int inLen, Array<byte> key)
Verifies that the tag stored at h is avalid tag for the message in whose lengthis inLen bytes, and the key k.
- Parameters:
tag- The tag.in- The message.inLen- Message bytes.key- The key as generated by cryptoAuthKeygen.
-
cryptoAuthKeygen
void cryptoAuthKeygen(Array<byte> k)
Generate an authentication key.
- Parameters:
k- Auth key of size KEYBYTES.
-
cryptoAuthKeygen
Key cryptoAuthKeygen()
Generate an authentication key.
-
cryptoAuth
String cryptoAuth(String message, Key key)
Computes a tag for the message in.
- Parameters:
message- A message.key- The key as generated by cryptoAuthKeygen.
-
cryptoAuthVerify
boolean cryptoAuthVerify(String tag, String message, Key key)
Verifies that the tagvalid tag for the message.
- Parameters:
tag- The tag.key- The key as generated by cryptoAuthKeygen.
-
cryptoAuthHMACSha256Keygen
void cryptoAuthHMACSha256Keygen(Array<byte> key)
-
cryptoAuthHMACSha256
boolean cryptoAuthHMACSha256(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha256Verify
boolean cryptoAuthHMACSha256Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha256Init
boolean cryptoAuthHMACSha256Init(Auth.StateHMAC256 state, Array<byte> key, int keyLen)
-
cryptoAuthHMACSha256Update
boolean cryptoAuthHMACSha256Update(Auth.StateHMAC256 state, Array<byte> in, int inLen)
-
cryptoAuthHMACSha256Final
boolean cryptoAuthHMACSha256Final(Auth.StateHMAC256 state, Array<byte> out)
-
cryptoAuthHMACSha512Keygen
void cryptoAuthHMACSha512Keygen(Array<byte> key)
-
cryptoAuthHMACSha512
boolean cryptoAuthHMACSha512(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha512Verify
boolean cryptoAuthHMACSha512Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha512Init
boolean cryptoAuthHMACSha512Init(Auth.StateHMAC512 state, Array<byte> key, int keyLen)
-
cryptoAuthHMACSha512Update
boolean cryptoAuthHMACSha512Update(Auth.StateHMAC512 state, Array<byte> in, int inLen)
-
cryptoAuthHMACSha512Final
boolean cryptoAuthHMACSha512Final(Auth.StateHMAC512 state, Array<byte> out)
-
cryptoAuthHMACSha512256Keygen
void cryptoAuthHMACSha512256Keygen(Array<byte> key)
-
cryptoAuthHMACSha512256
boolean cryptoAuthHMACSha512256(Array<byte> out, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha512256Verify
boolean cryptoAuthHMACSha512256Verify(Array<byte> h, Array<byte> in, int inLen, Array<byte> k)
-
cryptoAuthHMACSha512256Init
boolean cryptoAuthHMACSha512256Init(Auth.StateHMAC512256 state, Array<byte> key, int keyLen)
-
cryptoAuthHMACSha512256Update
boolean cryptoAuthHMACSha512256Update(Auth.StateHMAC512256 state, Array<byte> in, int inLen)
-
cryptoAuthHMACSha512256Final
boolean cryptoAuthHMACSha512256Final(Auth.StateHMAC512256 state, Array<byte> out)
-
cryptoAuthHMACShaKeygen
Key cryptoAuthHMACShaKeygen(Auth.Type type)
-
cryptoAuthHMACSha
String cryptoAuthHMACSha(Auth.Type type, String in, Key key)
-
cryptoAuthHMACShaVerify
boolean cryptoAuthHMACShaVerify(Auth.Type type, String h, String in, Key key)
-
cryptoAuthHMACShaInit
boolean cryptoAuthHMACShaInit(Auth.StateHMAC256 state, Key key)
-
cryptoAuthHMACShaUpdate
boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC256 state, String in)
-
cryptoAuthHMACShaFinal
String cryptoAuthHMACShaFinal(Auth.StateHMAC256 state)
-
cryptoAuthHMACShaInit
boolean cryptoAuthHMACShaInit(Auth.StateHMAC512 state, Key key)
-
cryptoAuthHMACShaUpdate
boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC512 state, String in)
-
cryptoAuthHMACShaFinal
String cryptoAuthHMACShaFinal(Auth.StateHMAC512 state)
-
cryptoAuthHMACShaInit
boolean cryptoAuthHMACShaInit(Auth.StateHMAC512256 state, Key key)
-
cryptoAuthHMACShaUpdate
boolean cryptoAuthHMACShaUpdate(Auth.StateHMAC512256 state, String in)
-
cryptoAuthHMACShaFinal
String cryptoAuthHMACShaFinal(Auth.StateHMAC512256 state)
-
cryptoShortHash
boolean cryptoShortHash(Array<byte> out, Array<byte> in, int inLen, Array<byte> key)
Short-input hash some text.
- Parameters:
out- The hashed text of size SIPHASH24_BYTES orSIPHASHX24_BYTES depending on{@code in}size.in- The short-input text to hash of size BYTES or of size SIPHASHX24_BYTES.inLen- The length of the short-input.key- The key generated via cryptoShortHashKeygen.
-
cryptoShortHashKeygen
void cryptoShortHashKeygen(Array<byte> k)
Output a 64-bit key.
- Parameters:
k- The key of size SIPHASH24_KEYBYTES.
-
cryptoShortHash
String cryptoShortHash(Array<byte> inBytes, Key key)
Hash a short message using a key.
- Parameters:
key- The key generated via cryptoShortHashKeygen.
-
cryptoShortHashStr
String cryptoShortHashStr(String in, Key key)
Hash a short string using a key.
- Parameters:
in- The short message to hash.key- The key generated via cryptoShortHashKeygen.
-
cryptoShortHashHex
String cryptoShortHashHex(String hexIn, Key key)
Hash a short hexadecimal string using a key.
- Parameters:
hexIn- The short message to hash, represented as hexadecimal string.key- The key generated via cryptoShortHashKeygen.
-
cryptoShortHashKeygen
Key cryptoShortHashKeygen()
Generate a 64-bit key for short-input hashing.
-
cryptoGenericHash
boolean cryptoGenericHash(Array<byte> out, int outLen, Array<byte> in, int inLen, Array<byte> key, int keyLen)
Hash a byte array.
- Parameters:
out- A place to store the resulting byte array.outLen- Size of out.in- The text to hash.inLen- The size of in.key- The key generated by cryptoGenericHashKeygen.keyLen- The length of the key.
-
cryptoGenericHash
boolean cryptoGenericHash(Array<byte> out, int outLen, Array<byte> in, int inLen)
Hash a byte array without a key.
- Parameters:
out- A place to store the resulting byte array.outLen- Size of out.in- The text to hash.inLen- The size of in.
-
cryptoGenericHashInit
boolean cryptoGenericHashInit(GenericHash.State state, Array<byte> key, int keyLength, int outLen)
Hash multiple parts of a message.
- Parameters:
state- The state which holds the current statein memory for further hashing.key- The key generated by cryptoGenericHashKeygen.keyLength- Length of the key.outLen- The size of the hash array.
-
cryptoGenericHashInit
boolean cryptoGenericHashInit(GenericHash.State state, int outLen)
Hash multiple parts of a message without a key
- Parameters:
state- The state which holds the current statein memory for further hashing.outLen- The size of the hash array.
-
cryptoGenericHashUpdate
boolean cryptoGenericHashUpdate(GenericHash.State state, Array<byte> in, int inLen)
Update a multi-part hashing with another part.
- Parameters:
state- The state.in- Another hash part.inLen- The length if the hash part.
-
cryptoGenericHashFinal
boolean cryptoGenericHashFinal(GenericHash.State state, Array<byte> out, int outLen)
Now that the hash has finalised, the hash canbe put into
{@code out}.- Parameters:
state- The state.out- The final hash.outLen- The length of the hash.
-
cryptoGenericHashKeygen
void cryptoGenericHashKeygen(Array<byte> k)
Generate a key. Store the key in
{@code k}.- Parameters:
k- A place to store the generated keyof size KEYBYTES.
-
cryptoGenericHashKeygen
Key cryptoGenericHashKeygen()
Generate a hashing key.
-
cryptoGenericHashKeygen
Key cryptoGenericHashKeygen(int size)
Generate a hashing key with a size.
- Parameters:
size- The size of the hashing key betweenKEYBYTES and KEYBYTES_MAX.
-
cryptoGenericHash
String cryptoGenericHash(String in, Key key)
Hash a string with a key, so later on youcan verify the hashed string with the key.If you're hashing a password please see cryptoPwHashString}instead.
- Parameters:
in- The string to hash.key- Can be null.
-
cryptoGenericHash
String cryptoGenericHash(String in)
Hash a string without a key.
- Parameters:
in- The string to hash.
-
cryptoGenericHashInit
boolean cryptoGenericHashInit(GenericHash.State state, Key key, int outLen)
Initialise a multi-part hashing operation.
- Parameters:
state- The state which holds the key and operation.key- The key as generated by cryptoGenericHashKeygen.outLen- The size of the final hash.
-
cryptoGenericHashUpdate
boolean cryptoGenericHashUpdate(GenericHash.State state, String in)
Hash a part of a multi-part hash.
- Parameters:
state- State as put into cryptoGenericHashInit.in- A part of a string to hash.
-
cryptoGenericHashFinal
String cryptoGenericHashFinal(GenericHash.State state, int outLen)
Finalise the hashing operation.
- Parameters:
state- State as put into cryptoGenericHashInit.outLen- The size of the final hash.
-
cryptoAeadChaCha20Poly1305Keygen
void cryptoAeadChaCha20Poly1305Keygen(Array<byte> key)
-
cryptoAeadChaCha20Poly1305Encrypt
boolean cryptoAeadChaCha20Poly1305Encrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
Encrypt a message
- Parameters:
nPub- Public nonce
-
cryptoAeadChaCha20Poly1305Encrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305Encrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
Encrypt a message (a deprecated overload)
- Parameters:
nSec- Unused parameter; should be{@code null}nPub- Public nonce
-
cryptoAeadChaCha20Poly1305Decrypt
boolean cryptoAeadChaCha20Poly1305Decrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305Decrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305Decrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305EncryptDetached
boolean cryptoAeadChaCha20Poly1305EncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305EncryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305EncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305DecryptDetached
boolean cryptoAeadChaCha20Poly1305DecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305DecryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305DecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfKeygen
void cryptoAeadChaCha20Poly1305IetfKeygen(Array<byte> key)
-
cryptoAeadChaCha20Poly1305IetfEncrypt
boolean cryptoAeadChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfEncrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfDecrypt
boolean cryptoAeadChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfDecrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfEncryptDetached
boolean cryptoAeadChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfEncryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfDecryptDetached
boolean cryptoAeadChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadChaCha20Poly1305IetfDecryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfKeygen
void cryptoAeadXChaCha20Poly1305IetfKeygen(Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfEncrypt
boolean cryptoAeadXChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfEncrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadXChaCha20Poly1305IetfEncrypt(Array<byte> c, Array<long> cLen, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfDecrypt
boolean cryptoAeadXChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfDecrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadXChaCha20Poly1305IetfDecrypt(Array<byte> m, Array<long> mLen, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfEncryptDetached
boolean cryptoAeadXChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfEncryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadXChaCha20Poly1305IetfEncryptDetached(Array<byte> c, Array<byte> mac, Array<long> macLenAddress, Array<byte> m, int mLen, Array<byte> ad, int adLen, Array<byte> nSec, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfDecryptDetached
boolean cryptoAeadXChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadXChaCha20Poly1305IetfDecryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadXChaCha20Poly1305IetfDecryptDetached(Array<byte> m, Array<byte> nSec, Array<byte> c, int cLen, Array<byte> mac, Array<byte> ad, int adLen, Array<byte> nPub, Array<byte> k)
-
cryptoAeadAES256GCMKeygen
void cryptoAeadAES256GCMKeygen(Array<byte> key)
-
cryptoAeadAES256GCMEncrypt
boolean cryptoAeadAES256GCMEncrypt(Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMEncrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadAES256GCMEncrypt(Array<byte> cipher, Array<long> cipherLen, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nSec, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMDecrypt
boolean cryptoAeadAES256GCMDecrypt(Array<byte> message, Array<long> messageLen, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMDecrypt
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadAES256GCMDecrypt(Array<byte> message, Array<long> messageLen, Array<byte> nSec, Array<byte> cipher, int cipherLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMEncryptDetached
boolean cryptoAeadAES256GCMEncryptDetached(Array<byte> cipher, Array<byte> mac, Array<long> macLenAddress, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMEncryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadAES256GCMEncryptDetached(Array<byte> cipher, Array<byte> mac, Array<long> macLenAddress, Array<byte> message, int messageLen, Array<byte> additionalData, int additionalDataLen, Array<byte> nSec, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMDecryptDetached
boolean cryptoAeadAES256GCMDecryptDetached(Array<byte> message, Array<byte> cipher, int cipherLen, Array<byte> mac, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMDecryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) boolean cryptoAeadAES256GCMDecryptDetached(Array<byte> message, Array<byte> nSec, Array<byte> cipher, int cipherLen, Array<byte> mac, Array<byte> additionalData, int additionalDataLen, Array<byte> nPub, Array<byte> key)
-
cryptoAeadAES256GCMIsAvailable
boolean cryptoAeadAES256GCMIsAvailable()
-
keygen
Key keygen(AEAD.Method method)
-
encrypt
String encrypt(String m, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)
-
encrypt
@Deprecated(forRemoval = true, since = 6.0.0) String encrypt(String m, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)
-
decrypt
String decrypt(String cipher, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)
-
decrypt
@Deprecated(forRemoval = true, since = 6.0.0) String decrypt(String cipher, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)
-
encryptDetached
DetachedEncrypt encryptDetached(String m, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)
-
encryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) DetachedEncrypt encryptDetached(String m, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)
-
decryptDetached
DetachedDecrypt decryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, Array<byte> nPub, Key k, AEAD.Method method)
-
decryptDetached
@Deprecated(forRemoval = true, since = 6.0.0) DetachedDecrypt decryptDetached(DetachedEncrypt detachedEncrypt, String additionalData, Array<byte> nSec, Array<byte> nPub, Key k, AEAD.Method method)
-
cryptoCoreRistretto255IsValidPoint
boolean cryptoCoreRistretto255IsValidPoint(Array<byte> point)
Returns whether the passed bytes represent a valid Ristretto255 point.
- Parameters:
point- the point to check, should be RISTRETTO255_BYTES bytes
-
cryptoCoreRistretto255Random
void cryptoCoreRistretto255Random(Array<byte> point)
Chooses a random Ristretto255 point and puts its representation to
{@code point}- Parameters:
point- the target array, must be RISTRETTO255_BYTES bytes
-
cryptoCoreRistretto255FromHash
boolean cryptoCoreRistretto255FromHash(Array<byte> point, Array<byte> hash)
Maps a RISTRETTO255_HASH_BYTES bytes hash to a Ristretto255 pointand puts its representation to
{@code point}.- Parameters:
point- the target array, must be RISTRETTO255_BYTES byteshash- the hash, must be RISTRETTO255_HASH_BYTES bytes
-
cryptoScalarmultRistretto255
boolean cryptoScalarmultRistretto255(Array<byte> result, Array<byte> n, Array<byte> point)
Multiplies the given Ristretto255
{@code point}by the scalar{@code n}and puts therepresentation of the result into{@code result}.- Parameters:
result- the target array, must be RISTRETTO255_BYTES bytesn- the scalar, must be RISTRETTO255_SCALAR_BYTES bytespoint- the Ristretto255 point, must be RISTRETTO255_BYTES bytes
-
cryptoScalarmultRistretto255Base
boolean cryptoScalarmultRistretto255Base(Array<byte> result, Array<byte> n)
Multiplies the Ristretto255 base point by the scalar
{@code n}and puts therepresentation of the result into{@code result}.- Parameters:
result- the target array, must be RISTRETTO255_BYTES bytesn- the scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255Add
boolean cryptoCoreRistretto255Add(Array<byte> result, Array<byte> p, Array<byte> q)
Adds two given Ristretto255 points
{@code p}and{@code q}and puts the representation ofthe result into{@code result}.- Parameters:
result- the target array, must be RISTRETTO255_BYTES bytesp- the first Ristretto255 point, must be RISTRETTO255_BYTES bytesq- the second Ristretto255 point, must be RISTRETTO255_BYTES bytes
-
cryptoCoreRistretto255Sub
boolean cryptoCoreRistretto255Sub(Array<byte> result, Array<byte> p, Array<byte> q)
Subtracts two given Ristretto255 points
{@code p}and{@code q}and puts therepresentation of the result into{@code result}.- Parameters:
result- the target array, must be RISTRETTO255_BYTES bytesp- the first Ristretto255 point, must be RISTRETTO255_BYTES bytesq- the second Ristretto255 point, must be RISTRETTO255_BYTES bytes
-
cryptoCoreRistretto255ScalarRandom
void cryptoCoreRistretto255ScalarRandom(Array<byte> scalar)
Creates a random scalar value in
{@code [0, l[}with{@code L}being the order of theRistretto255 group.- Parameters:
scalar- the target array, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarReduce
void cryptoCoreRistretto255ScalarReduce(Array<byte> result, Array<byte> scalar)
Reduces a possibly larger scalar value to
{@code [0, l[}with{@code L}being the orderof the Ristretto255 group.- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesscalar- the scalar to reduce, must be RISTRETTO255_NON_REDUCED_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarInvert
boolean cryptoCoreRistretto255ScalarInvert(Array<byte> result, Array<byte> scalar)
Calculates the multiplicative inverse of the given scalar value.
- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesscalar- the scalar to invert, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarNegate
void cryptoCoreRistretto255ScalarNegate(Array<byte> result, Array<byte> scalar)
Calculates the additive inverse of the given scalar value.
- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesscalar- the scalar to negate, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarComplement
void cryptoCoreRistretto255ScalarComplement(Array<byte> result, Array<byte> scalar)
Calculates the result R for the given scalar value such that
{@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesscalar- the scalar to complement, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarAdd
void cryptoCoreRistretto255ScalarAdd(Array<byte> result, Array<byte> x, Array<byte> y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesx- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarSub
void cryptoCoreRistretto255ScalarSub(Array<byte> result, Array<byte> x, Array<byte> y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesx- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarMul
void cryptoCoreRistretto255ScalarMul(Array<byte> result, Array<byte> x, Array<byte> y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
result- the target array, must be RISTRETTO255_SCALAR_BYTES bytesx- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255IsValidPoint
boolean cryptoCoreRistretto255IsValidPoint(String point)
Returns whether the passed encoded string represents a valid Ristretto255 point.
- Parameters:
point- the point to check
-
cryptoCoreRistretto255Random
Ristretto255.RistrettoPoint cryptoCoreRistretto255Random()
Chooses a random Ristretto255 point and returns it.
-
cryptoCoreRistretto255FromHash
Ristretto255.RistrettoPoint cryptoCoreRistretto255FromHash(String hash)
Maps a RISTRETTO255_HASH_BYTES bytes hash to a .
- Parameters:
hash- the encoded hash
-
cryptoCoreRistretto255FromHash
Ristretto255.RistrettoPoint cryptoCoreRistretto255FromHash(Array<byte> hash)
Maps a RISTRETTO255_HASH_BYTES bytes hash to a Ristretto255 point.
- Parameters:
hash- the hash, must be RISTRETTO255_HASH_BYTES
-
cryptoScalarmultRistretto255
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(BigInteger n, Ristretto255.RistrettoPoint point)
Multiplies the given Ristretto255
{@code point}by the scalar{@code n}and returns theresulting point.- Parameters:
n- the scalarpoint- the Ristretto255 point
-
cryptoScalarmultRistretto255
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(String nEnc, Ristretto255.RistrettoPoint point)
Multiplies the given Ristretto255
{@code point}by the scalar{@code n}and returns theresulting point.- Parameters:
nEnc- the encoded scalar bytes, in little-endian byte orderpoint- the Ristretto255 point
-
cryptoScalarmultRistretto255
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255(Array<byte> n, Ristretto255.RistrettoPoint point)
Multiplies the given Ristretto255
{@code point}by the scalar{@code n}and returns theresulting point.- Parameters:
n- the scalar, must be RISTRETTO255_BYTES bytes, inlittle-endian encodingpoint- the Ristretto255 point
-
cryptoScalarmultRistretto255Base
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(BigInteger n)
Multiplies the Ristretto255 base point by the scalar
{@code n}and returns the result.- Parameters:
n- the scalar
-
cryptoScalarmultRistretto255Base
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(String nEnc)
Multiplies the Ristretto255 base point by the scalar
{@code n}and returns the result.- Parameters:
nEnc- the encoded scalar, in little-endian byte order
-
cryptoScalarmultRistretto255Base
Ristretto255.RistrettoPoint cryptoScalarmultRistretto255Base(Array<byte> n)
Multiplies the Ristretto255 base point by the scalar
{@code n}and returns the result.- Parameters:
n- the scalar, must be RISTRETTO255_SCALAR_BYTES bytes, inlittle-endian encoding
-
cryptoCoreRistretto255Add
Ristretto255.RistrettoPoint cryptoCoreRistretto255Add(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q)
Adds two given Ristretto255 points
{@code p}and{@code q}and returns the result.- Parameters:
p- the first Ristretto255 pointq- the second Ristretto255 point
-
cryptoCoreRistretto255Sub
Ristretto255.RistrettoPoint cryptoCoreRistretto255Sub(Ristretto255.RistrettoPoint p, Ristretto255.RistrettoPoint q)
Subtracts two given Ristretto255 points
{@code p}and{@code q}and returns the result.- Parameters:
p- the first Ristretto255 pointq- the second Ristretto255 point
-
cryptoCoreRistretto255ScalarRandom
BigInteger cryptoCoreRistretto255ScalarRandom()
Creates a random scalar value in
{@code [0, l[}with{@code L}being the order of theRistretto255 group.
-
cryptoCoreRistretto255ScalarReduce
BigInteger cryptoCoreRistretto255ScalarReduce(BigInteger scalar)
Reduces a possibly larger scalar value to
{@code [0, l[}with{@code L}being the orderof the Ristretto255 group.- Parameters:
scalar- the scalar to reduce
-
cryptoCoreRistretto255ScalarReduce
BigInteger cryptoCoreRistretto255ScalarReduce(String scalarEnc)
Reduces a possibly larger scalar value to
{@code [0, l[}with{@code L}being the orderof the Ristretto255 group.- Parameters:
scalarEnc- the encoded scalar to reduce
-
cryptoCoreRistretto255ScalarReduce
BigInteger cryptoCoreRistretto255ScalarReduce(Array<byte> scalar)
Reduces a possibly larger scalar value to
{@code [0, L[}with{@code L}being the orderof the Ristretto255 group.- Parameters:
scalar- the scalar to reduce, must be RISTRETTO255_NON_REDUCED_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarInvert
BigInteger cryptoCoreRistretto255ScalarInvert(BigInteger scalar)
Calculates the multiplicative inverse of the given scalar value.
- Parameters:
scalar- the scalar to invert
-
cryptoCoreRistretto255ScalarInvert
BigInteger cryptoCoreRistretto255ScalarInvert(String scalarEnc)
Calculates the multiplicative inverse of the given scalar value.
- Parameters:
scalarEnc- the encoded scalar to invert
-
cryptoCoreRistretto255ScalarInvert
BigInteger cryptoCoreRistretto255ScalarInvert(Array<byte> scalar)
Calculates the multiplicative inverse of the given scalar value.
- Parameters:
scalar- the scalar to invert, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarNegate
BigInteger cryptoCoreRistretto255ScalarNegate(BigInteger scalar)
Calculates the additive inverse of the given scalar value.
- Parameters:
scalar- the scalar to negate
-
cryptoCoreRistretto255ScalarNegate
BigInteger cryptoCoreRistretto255ScalarNegate(String scalarEnc)
Calculates the additive inverse of the given scalar value.
- Parameters:
scalarEnc- the encoded scalar to negate
-
cryptoCoreRistretto255ScalarNegate
BigInteger cryptoCoreRistretto255ScalarNegate(Array<byte> scalar)
Calculates the additive inverse of the given scalar value.
- Parameters:
scalar- the scalar to negate, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarComplement
BigInteger cryptoCoreRistretto255ScalarComplement(BigInteger scalar)
Calculates the result R for the given scalar value such that
{@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.- Parameters:
scalar- the scalar to complement
-
cryptoCoreRistretto255ScalarComplement
BigInteger cryptoCoreRistretto255ScalarComplement(String scalarEnc)
Calculates the result R for the given scalar value such that
{@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.- Parameters:
scalarEnc- the encoded scalar to complement
-
cryptoCoreRistretto255ScalarComplement
BigInteger cryptoCoreRistretto255ScalarComplement(Array<byte> scalar)
Calculates the result R for the given scalar value such that
{@code R + scalar = 1 (mod * L)}with{@code L}being the order of the Ristretto255 group.- Parameters:
scalar- the scalar to complement, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(BigInteger x, BigInteger y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(BigInteger x, String y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(String x, BigInteger y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(String x, String y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(String x, Array<byte> y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(Array<byte> x, String y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(BigInteger x, Array<byte> y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(Array<byte> x, BigInteger y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar
-
cryptoCoreRistretto255ScalarAdd
BigInteger cryptoCoreRistretto255ScalarAdd(Array<byte> x, Array<byte> y)
Adds two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being the orderof the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(BigInteger x, BigInteger y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(BigInteger x, String y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(String x, BigInteger y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(String x, String y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(String x, Array<byte> y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(Array<byte> x, String y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(BigInteger x, Array<byte> y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(Array<byte> x, BigInteger y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar
-
cryptoCoreRistretto255ScalarSub
BigInteger cryptoCoreRistretto255ScalarSub(Array<byte> x, Array<byte> y)
Subtracts two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(BigInteger x, BigInteger y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(BigInteger x, String y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(String x, BigInteger y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(String x, String y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(String x, Array<byte> y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar (encoded)y- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(Array<byte> x, String y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar (encoded)
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(BigInteger x, Array<byte> y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalary- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(Array<byte> x, BigInteger y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar
-
cryptoCoreRistretto255ScalarMul
BigInteger cryptoCoreRistretto255ScalarMul(Array<byte> x, Array<byte> y)
Multiplies two scalars
{@code x}and{@code y}modulo{@code L}with{@code L}being theorder of the Ristretto255 group.- Parameters:
x- the first scalar, must be RISTRETTO255_SCALAR_BYTES bytesy- the second scalar, must be RISTRETTO255_SCALAR_BYTES bytes
-
res
<T> T res(int res, T object)
-
successful
boolean successful(int res)
-
str
String str(Array<byte> bs)
Converts a byte array to a stringusing a charset. This may not be what you want to use if you're storing this stringin a database for example. This function will produce null bytes and unexpectedcarriage returns. Please use sodiumBin2Hex to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.
- Parameters:
bs- The byte array.
-
str
String str(Array<byte> bs, Charset charset)
Convert a byte array to a string with a charset.This may not be what you want to use if you're storing this stringin a database for example. This function will produce null bytes and unexpectedcarriage returns. Please use sodiumBin2Hex to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.
- Parameters:
bs- Byte array.charset- The charset.
-
bytes
Array<byte> bytes(String s)
Convert a string to bytes using the configured charset.
- Parameters:
s- The String to convert to a byte array.
-
encodeToString
String encodeToString(Array<byte> bytes)
Encodes the given bytes, using this LazySodium's associated MessageEncoder.
- Parameters:
bytes- the bytes to encode
-
decodeFromString
Array<byte> decodeFromString(String encoded)
Decodes the given string to bytes, using this LazySodium's associated MessageEncoder.
- Parameters:
encoded- the encoded string
-
wrongLen
boolean wrongLen(int byteLength, int shouldBe)
-
wrongLen
boolean wrongLen(int byteLength, long shouldBe)
-
removeNulls
Array<byte> removeNulls(Array<byte> bs)
Remove all the null bytes from theend of a byte array.
- Parameters:
bs- A byte array.
-
-
-
-