{"name":"sodium-native","version":"2.4.6-rc","description":"Low level bindings for libsodium","main":"index.js","dependencies":{"ini":"^1.3.5","nan":"^2.14.0","node-gyp-build":"^4.1.0"},"devDependencies":{"prebuildify":"^3.0.2","sodium-test":"^0.7.0","sodium-vectors":"^1.0.0","standard":"^12.0.1","tape":"^4.6.3"},"scripts":{"dev":"node-gyp rebuild","fetch-libsodium":"git submodule update --recursive --init","test":"standard && tape \"test/*.js\"","install":"node-gyp-build \"node preinstall.js\" \"node postinstall.js\"","prebuild":"prebuildify -a --strip --preinstall \"node preinstall.js\" --postinstall \"node postinstall.js\"","prebuild-ia32":"prebuildify -a --strip --preinstall \"node preinstall.js\" --postinstall \"node postinstall.js\" --arch=ia32"},"repository":{"type":"git","url":"git+https://github.com/sodium-friends/sodium-native.git"},"contributors":[{"name":"Emil Bay","email":"github@tixz.dk","url":"http://bayes.dk"},{"name":"Mathias Buus","url":"@mafintosh"}],"license":"MIT","bugs":{"url":"https://github.com/sodium-friends/sodium-native/issues"},"homepage":"https://github.com/sodium-friends/sodium-native","gitHead":"3634e5dd4b81266abfd7ca47b6c10936f49965d1","readme":"# sodium-native\n[![build status](https://travis-ci.org/sodium-friends/sodium-native.svg?branch=master)](https://travis-ci.org/sodium-friends/sodium-native)\n\nLow level bindings for [libsodium](https://github.com/jedisct1/libsodium).\n\n```\nnpm install sodium-native\n```\n\nThe goal of this project is to be thin, stable, unopionated wrapper around libsodium.\n\nAll methods exposed are more or less a direct translation of the libsodium c-api.\nThis means that most data types are buffers and you have to manage allocating return values and passing them in as arguments intead of receiving them as return values.\n\nThis makes this API harder to use than other libsodium wrappers out there, but also means that you'll be able to get a lot of perf / memory improvements as you can do stuff like inline encryption / decryption, re-use buffers etc.\n\nThis also makes this library useful as a foundation for more high level crypto abstractions that you want to make.\n\n## Usage\n\n``` js\nvar sodium = require('sodium-native')\n\nvar nonce = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES)\nvar key = sodium.sodium_malloc(sodium.crypto_secretbox_KEYBYTES) // secure buffer\nvar message = Buffer.from('Hello, World!')\nvar ciphertext = Buffer.alloc(message.length + sodium.crypto_secretbox_MACBYTES)\n\nsodium.randombytes_buf(nonce) // insert random data into nonce\nsodium.randombytes_buf(key)  // insert random data into key\n\n// encrypted message is stored in ciphertext.\nsodium.crypto_secretbox_easy(ciphertext, message, nonce, key)\n\nconsole.log('Encrypted message:', ciphertext)\n\nvar plainText = Buffer.alloc(ciphertext.length - sodium.crypto_secretbox_MACBYTES)\n\nif (!sodium.crypto_secretbox_open_easy(plainText, ciphertext, nonce, key)) {\n  console.log('Decryption failed!')\n} else {\n  console.log('Decrypted message:', plainText, '(' + plainText.toString() + ')')\n}\n```\n\n## API\n\n[**Go to docs for the latest release**](https://github.com/sodium-friends/sodium-native/tree/v2.3.0) (The following docs may be for a unreleased version)\n\n#### `var sodium = require('sodium-native')`\n\nLoads the bindings. If you get an module version error you probably need to reinstall the module because you switched node versions.\n\n### Memory Protection\n\nBindings to the secure memory API.\n[See the libsodium \"Securing memory allocations\" docs for more information](https://download.libsodium.org/doc/memory_management).\n\n#### `sodium.sodium_memzero(buffer)`\n\nZero out the data in `buffer`.\n\n#### `sodium.sodium_mlock(buffer)`\n\nLock the memory contained in `buffer`\n\n#### `sodium.sodium_munlock(buffer)`\n\nUnlock previously `sodium_mlock`ed memory contained in `buffer`. This will also `sodium_memzero` `buffer`\n\n#### `var buffer = sodium.sodium_malloc(size)`\n\nAllocate a buffer of `size` which is memory protected. See [libsodium docs](https://download.libsodium.org/doc/memory_management#guarded-heap-allocations) for details. Be aware that many Buffer methods may break the security guarantees of `sodium.sodium_malloc`'ed memory. To check if a `Buffer` is a \"secure\" buffer,\nyou can call access the getter `buffer.secure` which will be `true`.\n\n#### `sodium.sodium_mprotect_noaccess(buffer)`\n\nMake `buffer` allocated using `sodium.sodium_malloc` inaccessible, crashing the process if any access is attempted.\nNote that this will have no effect for normal `Buffer`s.\n\n#### `sodium.sodium_mprotect_readonly(buffer)`\n\nMake `buffer` allocated using `sodium.sodium_malloc` read-only, crashing the process if any writing is attempted.\nNote that this will have no effect for normal `Buffer`s.\n\n#### `sodium.sodium_mprotect_readwrite(buffer)`\n\nMake `buffer` allocated using `sodium.sodium_malloc` read-write, undoing `sodium_mprotect_noaccess` or `sodium_mprotect_readonly`.\nNote that this will have no effect for normal `Buffer`s.\n\n### Generating random data\n\nBindings to the random data generation API.\n[See the libsodium randombytes docs for more information](https://download.libsodium.org/doc/generating_random_data/).\n\n#### `var uint32 = sodium.randombytes_random()`\n\nGenerate a random 32-bit unsigned integer `[0, 0xffffffff]` (both inclusive)\n\n#### `var uint = sodium.randombytes_uniform(upper_bound)`\n\nGenerate a random 32-bit unsigned integer `[0, upper_bound)` (last exclusive).\n`upper_bound` must be `0xffffffff` at most.\n\n#### `sodium.randombytes_buf(buffer)`\n\nFill `buffer` with random data.\n\n#### `sodium.randombytes_buf_deterministic(buffer, seed)`\n\nFill `buffer` with random data, generated from `seed`. `seed` must be a Buffer\nof at least `sodium.randombytes_SEEDBYTES` length\n\n### Helpers\n\nBindings to various helper functions.\n[See the libsodium helpers docs for more information](https://download.libsodium.org/doc/helpers/).\n\n### `var bool = sodium.sodium_memcmp(b1, b2)`\n\nCompare `b1` with `b2`, in **constant-time** for `b1.length`.\n\n* `b1` must be `Buffer`\n* `b2` must be `Buffer` and must be `b1.length` bytes\n\nReturns `true` when equal, otherwise `false`.\n\n### `var direction = sodium.sodium_compare(b1, b2)`\n\nCompare `b1` with `b2`, regarding either as little-endian encoded number.\n\n* `b1` must be `Buffer`\n* `b2` must be `Buffer` and must be `b1.length` bytes\n\nReturns `1`, `0` or `-1` on whether `b1` is greater, equal or less than `b2`.\nThis is the same scheme as `Array.prototype.sort` expect.\n\n### `sodium.sodium_add(a, b)`\n\nAdds `b` to `a` (wrapping), regarding either as little-endian encoded number,\nand writing the result into `a`.\n\n* `a` must be `Buffer`\n* `b` must be `Buffer` and must be `a.length` bytes\n\n### `sodium.sodium_sub(a, b)`\n\nSubtractss `b` from `a` (wrapping), regarding either as little-endian encoded\nnumber, and writing the result into `a`.\n\n* `a` must be `Buffer`\n* `b` must be `Buffer` and must be `a.length` bytes\n\n### `sodium.sodium_increment(buf)`\n\nIncrement `buf` as a little-endian number. This operation is **constant-time**\nfor the length of `buf`.\n\n* `buf` must be `Buffer`\n\n### `var bool = sodium.sodium_is_zero(buf, len)`\n\nTest whether `buf` is all zero for `len` bytes. This operation is\n**constant-time** for `len`.\n\n* `len` must be integer at most the length of `buf`\n\nReturns `true` if all `len` bytes are zero, otherwise `false`.\n\n### Padding\n\nBindings to the padding API.\n[See the libsodium padding docs for more information](https://download.libsodium.org/doc/padding).\n\n#### `var paddedLength = sodium.sodium_pad(buf, unpaddedLength, blocksize)`\n\nPad `buf` with random data from index `unpaddedLength` up to closest multiple of\n`blocksize`.\n\n* `buf` must be `Buffer`\n* `unpadded_buflen` must be integer at most `buf.length`\n* `blocksize` must be integer greater than 1 but at most `buf.length`\n\nReturns the length of the padded data (so you may `.slice` the buffer to here).\n\n#### `var unpaddedLength = sodium.sodium_unpad(buf, paddedLength, blocksize)`\n\nCalculate `unpaddedLength` from a padded `buf` with `blocksize`\n\n* `buf` must be `Buffer`\n* `padded_buflen` must be integer at most `buf.length`\n* `blocksize` must be integer greater than 1 but at most `buf.length`\n\nReturns the length of the unpadded data (so you may `.slice` the buffer to here).\n\n### Signing\n\nBindings for the crypto_sign API.\n[See the libsodium crypto_sign docs for more information](https://download.libsodium.org/doc/public-key_cryptography/public-key_signatures).\n\n#### `crypto_sign_seed_keypair(publicKey, secretKey, seed)`\n\nCreate a new keypair based on a seed.\n\n* `publicKey` should be a buffer with length `crypto_sign_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer with length `crypto_sign_SECRETKEYBYTES`.\n* `seed` should be a buffer with length `crypto_sign_SEEDBYTES`.\n\nThe generated public and secret key will be stored in passed in buffers.\n\n#### `crypto_sign_keypair(publicKey, secretKey)`\n\nCreate a new keypair.\n\n* `publicKey` should be a buffer with length `crypto_sign_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer with length `crypto_sign_SECRETKEYBYTES`.\n\nThe generated public and secret key will be stored in passed in buffers.\n\n#### `crypto_sign(signedMessage, message, secretKey)`\n\nSign a message.\n\n* `signedMessage` should be a buffer with length `crypto_sign_BYTES + message.length`.\n* `message` should be a buffer of any length.\n* `secretKey` should be a secret key.\n\nThe generated signed message will be stored in `signedMessage`.\n\n#### `var bool = crypto_sign_open(message, signedMessage, publicKey)`\n\nVerify and open a message.\n\n* `message` should be a buffer with length `signedMessage.length - crypto_sign_BYTES`.\n* `signedMessage` at least `crypto_sign_BYTES` length.\n* `publicKey` should be a public key.\n\nWill return `true` if the message could be verified. Otherwise `false`.\nIf verified the originally signed message is stored in the `message` buffer.\n\n#### `crypto_sign_detached(signature, message, secretKey)`\n\nSame as `crypto_sign` except it only stores the signature.\n\n* `signature` should be a buffer with length `crypto_sign_BYTES`.\n* `message` should be a buffer of any length.\n* `secretKey` should be a secret key.\n\nThe generated signature is stored in `signature`.\n\n#### `var bool = crypto_sign_verify_detached(signature, message, publicKey)`\n\nVerify a signature.\n\n* `signature` should be a buffer with length `crypto_sign_BYTES`.\n* `message` should be a buffer of any length.\n* `publicKey` should be a public key.\n\nWill return `true` if the message could be verified. Otherwise `false`.\n\n#### `crypto_sign_ed25519_pk_to_curve25519(curve_pk, ed_pk)`\n\nConvert an ed25519 public key to curve25519 (which can be used with `box` and `scalarmult`)\n\n* `curve_pk` should be a buffer with length `crypto_box_PUBLICKEYBYTES`\n* `ed_pk` should be a buffer with length `crypto_sign_PUBLICKEYBYTES`\n\n#### `crypto_sign_ed25519_sk_to_curve25519(curve_sk, ed_sk)`\n\nConvert an ed25519 secret key to curve25519 (which can be used with `box` and `scalarmult`)\n\n* `curve_sk` should be a buffer with length `crypto_box_SECRETKEYBYTES`\n* `ed_sk` should be a buffer with length `crypto_sign_SECRETKEYBYTES`\n\n#### `crypto_sign_ed25519_sk_to_pk(pk, sk)`\n\nExtract an ed25519 public key from an ed25519 secret key\n\n* `pk` must be `Buffer` of at least `crypto_sign_PUBLICKEYBYTES` bytes\n* `sk` must be `Buffer` of at least `crypto_sign_SECRETKEYBYTES` bytes\n\n### Generic hashing\n\nBindings for the crypto_generichash API.\n[See the libsodium crypto_generichash docs for more information](https://download.libsodium.org/doc/hashing/generic_hashing).\n\n#### `crypto_generichash(output, input, [key])`\n\nHash a value with an optional key using the generichash method.\n\n* `output` should be a buffer with length within `crypto_generichash_BYTES_MIN` - `crypto_generichash_BYTES_MAX`.\n* `input` should be a buffer of any length.\n* `key` is an optional buffer of length within `crypto_generichash_KEYBYTES_MIN` - `crypto_generichash_KEYBYTES_MAX`.\n\nThe generated hash is stored in `output`.\n\nAlso exposes `crypto_generichash_BYTES` and `crypto_generichash_KEYBYTES` that can be used as \"default\" buffer sizes.\n\n#### `crypto_generichash_batch(output, inputArray, [key])`\n\nSame as `crypto_generichash` except this hashes an array of buffers instead of a single one.\n\n#### `var instance = crypto_generichash_instance([key], [outputLength])`\n\nCreate a generichash instance that can hash a stream of input buffers.\n\n* `key` is an optional buffer as above.\n* `outputLength` the buffer size of your output.\n\n#### `instance.update(input)`\n\nUpdate the instance with a new piece of data.\n\n* `input` should be a buffer of any size.\n\n#### `instance.final(output)`\n\nFinalize the instance.\n\n* `output` should be a buffer as above with the same length you gave when creating the instance.\n\nThe generated hash is stored in `output`.\n\n### Public / secret key box encryption\n\nBindings for the crypto_box API.\n[See the libsodium crypto_box docs for more information](https://download.libsodium.org/doc/public-key_cryptography/authenticated_encryption).\n\n#### `crypto_box_seed_keypair(publicKey, secretKey, seed)`\n\nCreate a new keypair based on a seed.\n\n* `publicKey` should be a buffer with length `crypto_box_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer with length `crypto_box_SECRETKEYBYTES`.\n* `seed` should be a buffer with length `crypto_box_SEEDBYTES`.\n\nThe generated public and secret key will be stored in passed in buffers.\n\n#### `crypto_box_keypair(publicKey, secretKey)`\n\nCreate a new keypair.\n\n* `publicKey` should be a buffer with length `crypto_box_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer with length `crypto_box_SECRETKEYBYTES`.\n\nThe generated public and secret key will be stored in passed in buffers.\n\n#### `crypto_box_detached(ciphertext, mac, message, nonce, publicKey, secretKey)`\n\nEncrypt a message.\n\n* `ciphertext` should be a buffer with length `message.length`.\n* `mac` should be a buffer with length `crypto_box_MACBYTES`.\n* `message` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_box_NONCEBYTES`.\n* `publicKey` should be a public key.\n* `secretKey` should be a secret key.\n\nThe encrypted message will be stored in `ciphertext` and the authentification code will be stored in `mac`.\n\n#### `crypto_box_easy(ciphertext, message, nonce, publicKey, secretKey)`\n\nSame as `crypto_box_detached` except it encodes the mac in the message.\n\n* `ciphertext` should be a buffer with length `message.length + crypto_box_MACBYTES`.\n* `message` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_box_NONCEBYTES`.\n* `publicKey` should be a public key.\n* `secretKey` should be a secret key.\n\nThe encrypted message and authentification code  will be stored in `ciphertext`.\n\n#### `var bool = crypto_box_open_detached(message, ciphertext, mac, nonce, publicKey, secretKey)`\n\nDecrypt a message.\n\n* `message` should be a buffer with length `ciphertext.length`.\n* `mac` should be a buffer with length `crypto_box_MACBYTES`.\n* `ciphertext` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_box_NONCEBYTES`.\n* `publicKey` should be a public key.\n* `secretKey` should be a secret key.\n\nReturns `true` if the message could be decrypted. Otherwise `false`.\n\nThe decrypted message will be stored in `message`.\n\n#### `var bool = crypto_box_open_easy(message, ciphertext, nonce, publicKey, secretKey)`\n\nDecrypt a message encoded with the easy method.\n\n* `message` should be a buffer with length `ciphertext.length - crypto_box_MACBYTES`.\n* `ciphertext` should be a buffer with length at least `crypto_box_MACBYTES`.\n* `nonce` should be a buffer with length `crypto_box_NONCEBYTES`.\n* `publicKey` should be a public key.\n* `secretKey` should be a secret key.\n\nReturns `true` if the message could be decrypted. Otherwise `false`.\n\nThe decrypted message will be stored in `message`.\n\n### Sealed box encryption\n\nBindings for the crypto_box_seal API.\n[See the libsodium crypto_box_seal docs for more information](https://download.libsodium.org/doc/public-key_cryptography/sealed_boxes).\n\nKeypairs can be generated with `crypto_box_keypair()` or `crypto_box_seed_keypair()`.\n\n#### `crypto_box_seal(ciphertext, message, publicKey)`\n\nEncrypt a message in a sealed box using a throwaway keypair.\nThe ciphertext cannot be associated with the sender due to the sender's key\nbeing a single use keypair that is overwritten during encryption.\n\n* `ciphertext` should be a buffer with length at least `message.length + crypto_box_SEALBYTES`.\n* `message` should be a buffer with any length.\n* `publicKey` should be the receipent's public key.\n\n#### `var bool = crypto_box_seal_open(message, ciphertext, publicKey, secretKey)`\n\nDecrypt a message encoded with the sealed box method.\n\n* `message` should be a buffer with length at least  `ciphertext.length - crypto_box_SEALBYTES`.\n* `ciphertext` should be a buffer with length at least `crypto_box_SEALBYTES`.\n* `publicKey` should be the receipient's public key.\n* `secretKey` should be the receipient's secret key.\n\nNote: the keypair of the recipient is required here, both public and secret key.\nThis is because during encryption the recipient's public key is used to generate\nthe nonce. The throwaway public key generated by the sender is stored in the first\n`crypto_box_PUBLICKEYBYTE`'s of the ciphertext.\n\n### Secret key box encryption\n\nBindings for the crypto_secretbox API.\n[See the libsodium crypto_secretbox docs for more information](https://download.libsodium.org/doc/public-key_cryptography/authenticated_encryption).\n\n#### `crypto_secretbox_detached(ciphertext, mac, message, nonce, secretKey)`\n\nEncrypt a message.\n\n* `ciphertext` should be a buffer with length `message.length`.\n* `mac` should be a buffer with length `crypto_secretbox_MACBYTES`.\n* `message` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_secretbox_NONCEBYTES`.\n* `secretKey` should be a secret key with legnth `crypto_secretbox_KEYBYTES`.\n\nThe encrypted message will be stored in `ciphertext` and the authentification code will be stored in `mac`.\n\n#### `crypto_secretbox_easy(ciphertext, message, nonce, secretKey)`\n\nSame as `crypto_secretbox_detached` except it encodes the mac in the message.\n\n* `ciphertext` should be a buffer with length `message.length + crypto_secretbox_MACBYTES`.\n* `message` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_secretbox_NONCEBYTES`.\n* `secretKey` should be a secret key with legnth `crypto_secretbox_KEYBYTES`.\n\n#### `var bool = crypto_secretbox_open_detached(message, ciphertext, mac, nonce, secretKey)`\n\nDecrypt a message.\n\n* `message` should be a buffer with length `ciphertext.length`.\n* `mac` should be a buffer with length `crypto_secretbox_MACBYTES`.\n* `ciphertext` should be a buffer of any length.\n* `nonce` should be a buffer with length `crypto_secretbox_NONCEBYTES`.\n* `secretKey` should be a secret key.\n\nReturns `true` if the message could be decrypted. Otherwise `false`.\n\nThe decrypted message will be stored in `message`.\n\n#### `var bool = crypto_secretbox_open_easy(message, ciphertext, nonce, secretKey)`\n\nDecrypt a message encoded with the easy method.\n\n* `message` should be a buffer with length `ciphertext.length - crypto_secretbox_MACBYTES`.\n* `ciphertext` should be a buffer with length at least `crypto_secretbox_MACBYTES`.\n* `nonce` should be a buffer with length `crypto_secretbox_NONCEBYTES`.\n* `secretKey` should be a secret key.\n\nReturns `true` if the message could be decrypted. Otherwise `false`.\n\nThe decrypted message will be stored in `message`.\n\n### AEAD (Authenticated Encryption with Additional Data)\n\nBindings for the crypto_aead_* APIs.\n[See the libsodium AEAD docs for more information](https://download.libsodium.org/doc/secret-key_cryptography/aead).\n\nCurrently only `crypto_aead_xchacha20poly1305_ietf` is exposed.\n\n### Constants\n\n#### Buffer lengths (Integer)\n\n- `crypto_aead_xchacha20poly1305_ietf_ABYTES`\n- `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`\n- `crypto_aead_xchacha20poly1305_ietf_NPUBBYTES`\n- `crypto_aead_xchacha20poly1305_ietf_NSECBYTES`\n- `crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX` - Note this is `Number.MAX_SAFE_INTEGER` for now\n\n#### `crypto_aead_xchacha20poly1305_ietf_keygen(key)`\n\nGenerate a new encryption key.\n\n* `key` should be a buffer of length `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`.\n\nThe generated key is stored in `key`.\n\n### `var clen = crypto_aead_xchacha20poly1305_ietf_encrypt(ciphertext, message, [ad], null, npub, key)`\n\nEncrypt a message with (`npub`, `key`) and optional additional data `ad`.\n\n* `ciphertext` should be a `Buffer` of size\n  `message.length + crypto_aead_xchacha20poly1305_ietf_ABYTES`.\n* `message` should be a `Buffer`.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of authentication tag appended to the message.\n* `null` is in the position of the unused `nsec` argument. This should always be\n  `null`.\n* `npub` should be `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_NPUBBYTES`.\n* `key` should be a `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`.\n\nReturns how many bytes were written to `ciphertext`. Note that in-place\nencryption is possible.\n\n### `var mlen = crypto_aead_xchacha20poly1305_ietf_decrypt(message, null, ciphertext, [ad], npub, key)`\n\nDecrypt a message with (`npub`, `key`) and optional additional data `ad`.\n\n* `message` should be a `Buffer` of size\n  `ciphertext.length - crypto_aead_xchacha20poly1305_ietf_ABYTES`.\n* `null` is in the position of the unused `nsec` argument. This should always be\n  `null`.\n* `ciphertext` should be a `Buffer`.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of authentication tag appended to the message.\n* `npub` should be `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_NPUBBYTES`.\n* `key` should be a `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`.\n\nReturns how many bytes were written to `message`. Note that in-place\nencryption is possible.\n\n### `var maclen = crypto_aead_xchacha20poly1305_ietf_encrypt_detached(ciphertext, mac, message, [ad], null, npub, key)`\n\nEncrypt a message with (`npub`, `key`) and optional additional data `ad`.\n\n* `ciphertext` should be a `Buffer` of size `message.length`.\n* `mac` should be `Buffer` of size `crypto_aead_xchacha20poly1305_ietf_ABYTES`.\n* `message` should be a `Buffer`.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of authentication tag appended to the message.\n* `null` is in the position of the unused `nsec` argument. This should always be\n  `null`.\n* `npub` should be `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_NPUBBYTES`.\n* `key` should be a `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`.\n\nReturns how many bytes were written to `mac`. Note that in-place\nencryption is possible.\n\n### `crypto_aead_xchacha20poly1305_ietf_decrypt_detached(message, null, ciphertext, mac, [ad], npub, key)`\n\nDecrypt a message with (`npub`, `key`) and optional additional data `ad`.\n\n* `message` should be a `Buffer` of size `ciphertext.length`.\n* `null` is in the position of the unused `nsec` argument. This should always be\n  `null`.\n* `ciphertext` should be a `Buffer`.\n* `mac` should be `Buffer` of size `crypto_aead_xchacha20poly1305_ietf_ABYTES`.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of authentication tag appended to the message.\n* `npub` should be `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_NPUBBYTES`.\n* `key` should be a `Buffer` of length `crypto_aead_xchacha20poly1305_ietf_KEYBYTES`.\n\nReturns nothing, but will throw on in case the MAC cannot be authenticated. Note\nthat in-place encryption is possible.\n\n### Non-authenticated streaming encryption\n\nBindings for the crypto_stream API.\n[See the libsodium crypto_stream docs for more information](https://download.libsodium.org/doc/advanced/stream_ciphers/xsalsa20).\n\n#### `crypto_stream(ciphertext, nonce, key)`\n\nGenerate random data based on a nonce and key into the ciphertext.\n\n* `ciphertext` should be a buffer of any size.\n* `nonce` should be a buffer with length `crypto_stream_NONCEBYTES`.\n* `key` should be a secret key with length `crypto_stream_KEYBYTES`.\n\nThe generated data is stored in `ciphertext`.\n\n#### `crypto_stream_xor(ciphertext, message, nonce, key)` or\n#### `crypto_stream_chacha20_xor(ciphertext, message, nonce, key)`\n\nEncrypt, but *not* authenticate, a message based on a nonce and key\n\n* `ciphertext` should be a buffer with length `message.length`.\n* `message` should be a buffer of any size.\n* `nonce` should be a buffer with length `crypto_stream_NONCEBYTES`.\n* `key` should be a secret key with length `crypto_stream_KEYBYTES`.\n\nThe encrypted data is stored in `ciphertext`. To decrypt, swap `ciphertext` and `message`.\nAlso supports in-place encryption where you use the same buffer as `ciphertext` and `message`.\n\nEncryption defaults to XSalsa20, use `crypto_stream_chacha20_xor` if you want\nto encrypt/decrypt with ChaCha20 instead.\n\n#### `var instance = crypto_stream_xor_instance(nonce, key)` or\n#### `var instance = crypto_stream_chacha20_xor_instance(nonce, key)`\n\nA streaming instance to the `crypto_stream_xor` api. Pass a nonce and key in the constructor.\n\nEncryption defaults to XSalsa20, use `crypto_stream_chacha20_xor_instance` if\nyou want to encrypt/decrypt with ChaCha20 instead.\n\n#### `instance.update(ciphertext, message)`\n\nEncrypt the next message\n\n#### `instance.final()`\n\nFinalize the stream. Zeros out internal state.\n\n### Authentication\n\nBindings for the crypto_auth API.\n[See the libsodium crypto_auth docs for more information](https://download.libsodium.org/doc/secret-key_cryptography/secret-key_authentication).\n\n#### `crypto_auth(output, input, key)`\n\nCreate an authentication token.\n\n* `output` should be a buffer of length `crypto_auth_BYTES`.\n* `input` should be a buffer of any size.\n* `key` should be a buffer of lenght `crypto_auth_KEYBYTES`.\n\nThe generated token is stored in `output`.\n\n#### `var bool = crypto_auth_verify(output, input, key)`\n\nVerify a token.\n\n* `output` should be a buffer of length `crypto_auth_BYTES`.\n* `input` should be a buffer of any size.\n* `key` should be a buffer of lenght `crypto_auth_KEYBYTES`.\n\nReturns `true` if the token could be verified. Otherwise `false`.\n\n### Stream encryption\n\nBindings for the crypto_secretstream API.\n[See the libsodium crypto_secretstream docs for more information](https://download.libsodium.org/doc/secret-key_cryptography/secretstream).\n\n### Constants\n\n#### Buffer lengths (Integer)\n\n- `crypto_secretstream_xchacha20poly1305_ABYTES`\n- `crypto_secretstream_xchacha20poly1305_HEADERBYTES`\n- `crypto_secretstream_xchacha20poly1305_KEYBYTES`\n- `crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX`\n- `crypto_secretstream_xchacha20poly1305_TAGBYTES` - NOTE: Unofficial constant\n\n#### Message tags (`Buffer`)\n\n- `crypto_secretstream_xchacha20poly1305_TAG_MESSAGE`\n- `crypto_secretstream_xchacha20poly1305_TAG_PUSH`\n- `crypto_secretstream_xchacha20poly1305_TAG_REKEY`\n- `crypto_secretstream_xchacha20poly1305_TAG_FINAL`\n\n### `crypto_secretstream_xchacha20poly1305_keygen(key)`\n\nGenerate a new encryption key.\n\n* `key` should be a buffer of length `crypto_secretstream_xchacha20poly1305_KEYBYTES`.\n\nThe generated key is stored in `key`.\n\n### `var state = crypto_secretstream_xchacha20poly1305_state_new()`\n\nCreate a new stream state. Returns an opaque object used in the next methods.\n\n### `crypto_secretstream_xchacha20poly1305_init_push(state, header, key)`\n\nInitialise `state` from the writer side with message `header` and\nencryption key `key`. The header must be sent or stored with the stream.\nThe key must be exchanged securely with the receiving / reading side.\n\n* `state` should be an opaque state object.\n* `header` should be a buffer of size `crypto_secretstream_xchacha20poly1305_HEADERBYTES`.\n* `key` should be a buffer of length `crypto_secretstream_xchacha20poly1305_KEYBYTES`.\n\n### `var mlen = crypto_secretstream_xchacha20poly1305_push(state, ciphertext, message, [ad], tag)`\n\nEncrypt a message with a certain tag and optional additional data `ad`.\n\n* `state` should be an opaque state object.\n* `ciphertext` should be a buffer of size `message.length + crypto_secretstream_xchacha20poly1305_ABYTES`.\n* `message` should be a buffer.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of authentication tag appended to the message.\n* `tag` should be `Buffer` of length `crypto_secretstream_xchacha20poly1305_TAGBYTES`\n\nNote that `tag` should be one of the `crypto_secretstream_xchacha20poly1305_TAG_*` constants.\nReturns number of encrypted bytes written to `ciphertext`.\n\n### `crypto_secretstream_xchacha20poly1305_init_pull(state, header, key)`\n\nInitialise `state` from the reader side with message `header` and\nencryption key `key`. The header must be retrieved from somewhere.\nThe key must be exchanged securely with the sending / writing side.\n\n* `state` should be an opaque state object.\n* `header` should be a buffer of size `crypto_secretstream_xchacha20poly1305_HEADERBYTES`.\n* `key` should be a buffer of length `crypto_secretstream_xchacha20poly1305_KEYBYTES`.\n\n### `var clen = crypto_secretstream_xchacha20poly1305_pull(state, message, tag, ciphertext, [ad])`\n\nDecrypt a message with optional additional data `ad`, and write message tag to\n`tag`. Make sure to check this!\n\n* `state` should be an opaque state object.\n* `message` should be a buffer of size `ciphertext.length - crypto_secretstream_xchacha20poly1305_ABYTES`.\n* `tag` should be a buffer of `crypto_secretstream_xchacha20poly1305_TAGBYTES`.\n* `ad` is optional and should be `null` or `Buffer`. Included in the computation\n  of the authentication tag appended to the message.\n\nNote that `tag` should be one of the `crypto_secretstream_xchacha20poly1305_TAG_*` constants.\nReturns number of decrypted bytes written to `message`.\n\n### `crypto_secretstream_xchacha20poly1305_rekey(state)`\n\nRekey the opaque `state` object.\n\n### One-time Authentication\n\nBindings for the crypto_onetimeauth API.\n[See the libsodium crypto_onetimeauth docs for more information](https://download.libsodium.org/doc/advanced/poly1305).\n\n#### `crypto_onetimeauth(output, input, key)`\n\nCreate a authentication token based on a onetime key.\n\n* `output` should be a buffer of length `crypto_onetimauth_BYTES`.\n* `input` should be a buffer of any size.\n* `key` should be a buffer of lenght `crypto_onetimeauth_KEYBYTES`.\n\nThe generated token is stored in `output`.\n\n#### `var bool = crypto_onetimeauth_verify(output, input, key)`\n\nVerify a token.\n\n* `output` should be a buffer of length `crypto_onetimeauth_BYTES`.\n* `input` should be a buffer of any size.\n* `key` should be a buffer of lenght `crypto_onetimeauth_KEYBYTES`.\n\nReturns `true` if the token could be verified. Otherwise `false`.\n\n#### `var instance = crypto_onetimeauth_instance(key)`\n\nCreate an instance that create a token from a onetime key and a stream of input data.\n\n* `key` should be a buffer of length `crypto_onetimeauth_KEYBYTES`.\n\n#### `instance.update(input)`\n\nUpdate the instance with a new piece of data.\n\n* `input` should be a buffer of any size.\n\n#### `instance.final(output)`\n\nFinalize the instance.\n\n* `output` should be a buffer of length `crypto_onetimeauth_BYTES`.\n\nThe generated hash is stored in `output`.\n\n### Password Hashing\n\nBindings for the crypto_pwhash API.\n[See the libsodium crypto_pwhash docs for more information](https://download.libsodium.org/doc/password_hashing/).\n\n#### `crypto_pwhash(output, password, salt, opslimit, memlimit, algorithm)`\n\nCreate a password hash.\n\n* `output` should be a buffer with length within `crypto_pwhash_BYTES_MIN` - `crypto_pwhash_BYTES_MAX`.\n* `password` should be a buffer of any size.\n* `salt` should be a buffer with length `crypto_pwhash_SALTBYTES`.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_OPSLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_MEMLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n* `algorithm` should be a number specifying the algorithm you want to use.\n\nAvailable default ops and mem limits are\n\n* `crypto_pwhash_OPSLIMIT_INTERACTIVE`\n* `crypto_pwhash_OPSLIMIT_MODERATE`\n* `crypto_pwhash_OPSLIMIT_SENSITIVE`\n* `crypto_pwhash_MEMLIMIT_INTERACTIVE`\n* `crypto_pwhash_MEMLIMIT_MODERATE`\n* `crypto_pwhash_MEMLIMIT_SENSITIVE`\n\nThe available algorithms are\n\n* `crypto_pwhash_ALG_DEFAULT`\n* `crypto_pwhash_ALG_ARGON2ID13`\n* `crypto_pwhash_ALG_ARGON2I13`\n\nThe generated hash will be stored in `output` and the entire `output` buffer will be used.\n\n#### `crypto_pwhash_str(output, password, opslimit, memlimit)`\n\nCreate a password hash with a random salt.\n\n* `output` should be a buffer with length `crypto_pwhash_STRBYTES`.\n* `password` should be a buffer of any size.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_OPSLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_MEMLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n\nThe generated hash, settings, salt, version and algorithm will be stored in `output` and the entire `output` buffer will be used.\n\n#### `var bool = crypto_pwhash_str_verify(str, password)`\n\nVerify a password hash generated with the above method.\n\n* `str` should be a buffer with length `crypto_pwhash_STRBYTES`.\n* `password` should be a buffer of any size.\n\nReturns `true` if the hash could be verified with the settings contained in `str`. Otherwise `false`.\n\n#### `var bool = crypto_pwhash_str_needs_rehash(hash, opslimit, memlimit)`\n\nCheck if a password hash needs rehash, either because the default algorithm\nchanged, opslimit or memlimit increased or because the hash is malformed.\n\n* `hash` should be a buffer with length `crypto_pwhash_STRBYTES`.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_OPSLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_MEMLIMIT_MIN` - `crypto_pwhash_OPSLIMIT_MAX`.\n\nReturns `true` if the hash should be rehashed the settings contained in `str`.\nOtherwise `false` if it is still good.\n\n#### `crypto_pwhash_async(output, password, salt, opslimit, memlimit, algorithm, callback)`\n\nJust like `crypto_pwhash` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err)` will receive any errors from the hashing but all argument errors will `throw`. The resulting hash is written to `output`. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_async`\n\n#### `crypto_pwhash_str_async(output, password, opslimit, memlimit, callback)`\n\nJust like `crypto_pwhash_str` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err)` will receive any errors from the hashing but all argument errors will `throw`. The resulting hash with parameters is written to `output`. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_str_async`\n\n#### `crypto_pwhash_str_verify_async(str, password, callback)`\n\nJust like `crypto_pwhash_str_verify` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err, bool)` will receive any errors from the hashing but all argument errors will `throw`. If the verification succeeds `bool` is `true`, otherwise `false`. Due to an issue with libsodium `err` is currently never set. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_str_verify_async`\n\n### Password Hashing (Scrypt)\n\nBindings for the crypto_pwhash_scryptsalsa208sha256 API.\n[See the libsodium crypto_pwhash_scryptsalsa208sha256 docs for more information](https://download.libsodium.org/doc/advanced/scrypt).\n\n#### `crypto_pwhash_scryptsalsa208sha256(output, password, salt, opslimit, memlimit)`\n\nCreate a password hash.\n\n* `output` should be a buffer with length within `crypto_pwhash_scryptsalsa208sha256_BYTES_MIN` - `crypto_pwhash_scryptsalsa208sha256_BYTES_MAX`.\n* `password` should be a buffer of any size.\n* `salt` should be a buffer with length `crypto_pwhash_scryptsalsa208sha256_SALTBYTES`.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n\nAvailable default ops and mem limits are\n\n* `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE`\n* `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE`\n* `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE`\n* `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE`\n\nThe generated hash will be stored in `output` and the entire `output` buffer will be used.\n\n#### `crypto_pwhash_scryptsalsa208sha256_str(output, password, opslimit, memlimit)`\n\nCreate a password hash with a random salt.\n\n* `output` should be a buffer with length `crypto_pwhash_scryptsalsa208sha256_STRBYTES`.\n* `password` should be a buffer of any size.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n\nThe generated hash, settings, salt, version and algorithm will be stored in `output` and the entire `output` buffer will be used.\n\n#### `var bool = crypto_pwhash_scryptsalsa208sha256_str_verify(str, password)`\n\nVerify a password hash generated with the above method.\n\n* `str` should be a buffer with length `crypto_pwhash_scryptsalsa208sha256_STRBYTES`.\n* `password` should be a buffer of any size.\n\nReturns `true` if the hash could be verified with the settings contained in `str`. Otherwise `false`.\n\n#### `var bool = crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(hash, opslimit, memlimit)`\n\nCheck if a password hash needs rehash, either because opslimit or memlimit\nincreased or because the hash is malformed.\n\n* `hash` should be a buffer with length `crypto_pwhash_scryptsalsa208sha256_STRBYTES`.\n* `opslimit` should a be number containing your ops limit setting in the range `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n* `memlimit` should a be number containing your mem limit setting in the range `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN` - `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX`.\n\nReturns `true` if the hash should be rehashed the settings contained in `str`.\nOtherwise `false` if it is still good.\n\n#### `crypto_pwhash_scryptsalsa208sha256_async(output, password, salt, opslimit, memlimit, callback)`\n\nJust like `crypto_pwhash_scryptsalsa208sha256` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err)` will receive any errors from the hashing but all argument errors will `throw`. The resulting hash is written to `output`. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_scryptsalsa208sha256_async`\n\n#### `crypto_pwhash_scryptsalsa208sha256_str_async(output, password, opslimit, memlimit, callback)`\n\nJust like `crypto_pwhash_scryptsalsa208sha256_str` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err)` will receive any errors from the hashing but all argument errors will `throw`. The resulting hash with parameters is written to `output`. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_scryptsalsa208sha256_str_async`\n\n#### `crypto_pwhash_scryptsalsa208sha256_str_verify_async(str, password, callback)`\n\nJust like `crypto_pwhash_scryptsalsa208sha256_str_verify` but will run password hashing on a seperate worker so it will not block the event loop. `callback(err, bool)` will receive any errors from the hashing but all argument errors will `throw`. If the verification succeeds `bool` is `true`, otherwise `false`. Due to an issue with libsodium `err` is currently never set. This function also supports [`async_hook`s](https://nodejs.org/dist/latest/docs/api/async_hooks.html) as the type `sodium-native:crypto_pwhash_scryptsalsa208sha256_str_verify_async`\n\n### Key exchange\n\nBindings for the crypto_kx API.\n[See the libsodium crypto_kx docs for more information](https://download.libsodium.org/doc/key_exchange/).\n\n#### `crypto_kx_keypair(publicKey, secretKey)`\n\nCreate a key exchange key pair.\n\n* `publicKey` should be a buffer of length `crypto_kx_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer of length `crypto_kx_SECRETKEYBYTES`.\n\n#### `crypto_kx_seed_keypair(publicKey, secretKey, seed)`\n\nCreate a key exchange key pair based on a seed.\n\n* `publicKey` should be a buffer of length `crypto_kx_PUBLICKEYBYTES`.\n* `secretKey` should be a buffer of length `crypto_kx_SECRETKEYBYTES`.\n* `seed` should be a buffer of length `crypto_kx_SEEDBYTES`\n\n#### `crypto_kx_client_session_keys(rx, tx, clientPublicKey, clientSecretKey, serverPublicKey)`\n\nGenerate a session receive and transmission key for a client.\nThe public / secret keys should be generated using the key pair method above.\n\n* `rx` should be a buffer of length `crypto_kx_SESSIONKEYBYTES` or `null`.\n* `tx` should be a buffer of length `crypto_kx_SESSIONKEYBYTES` or `null`.\n\nYou should use the `rx` to decrypt incoming data and `tx` to encrypt outgoing.\nIf you need to make a one-way or half-duplex channel you can give only one of\n`rx` or `tx`.\n\n#### `crypto_kx_server_session_keys(rx, tx, serverPublicKey, serverSecretKey, clientPublicKey)`\n\nGenerate a session receive and transmission key for a server.\nThe public / secret keys should be generated using the key pair method above.\n\n* `rx` should be a buffer of length `crypto_kx_SESSIONKEYBYTES` or `null`.\n* `tx` should be a buffer of length `crypto_kx_SESSIONKEYBYTES` or `null`.\n\nYou should use the `rx` to decrypt incoming data and `tx` to encrypt outgoing.\nIf you need to make a one-way or half-duplex channel you can give only one of\n`rx` or `tx`.\n\n### Diffie-Hellman\n\nBindings for the crypto_scalarmult API.\n[See the libsodium crypto_scalarmult docs for more information](https://download.libsodium.org/doc/advanced/scalar_multiplication).\n\n#### `crypto_scalarmult_base(publicKey, secretKey)`\n\nCreate a scalar multiplication public key based on a secret key\n\n* `publicKey` should be a buffer of length `crypto_scalarmult_BYTES`.\n* `secretKey` should be a buffer of length `crypto_scalarmult_SCALARBYTES`.\n\nThe generated public key is stored in `publicKey`.\n\n#### `crypto_scalarmult(sharedSecret, secretKey, remotePublicKey)`\n\nDerive a shared secret from a local secret key and a remote public key.\n\n* `sharedSecret` shoudl be a buffer of length `crypto_scalarmult_BYTES`.\n* `secretKey` should be a buffer of length `crypto_scalarmult_SCALARBYTES`.\n* `remotePublicKey` should be a buffer of length `crypto_scalarmult_BYTES`.\n\nThe generated shared secret is stored in `sharedSecret`.\n\n### Finite field aritmhetic\n\nBindings for the crypto_scalarmult_ed25519 and crypto_core_ed25519 API.\n[See the libsodium docs for more information](https://download.libsodium.org/doc/advanced/point-arithmetic).\n\n#### Constants\n\n* `crypto_scalarmult_ed25519_BYTES`\n* `crypto_scalarmult_ed25519_SCALARBYTES`\n* `crypto_core_ed25519_BYTES`\n* `crypto_core_ed25519_UNIFORMBYTES`\n* `crypto_core_ed25519_SCALARBYTES`\n* `crypto_core_ed25519_NONREDUCEDSCALARBYTES`\n\n#### `var bool = crypto_core_ed25519_is_valid_point(p)`\n\n> The crypto_core_ed25519_is_valid_point() function checks that p represents\n> a point on the edwards25519 curve, in canonical form, on the main subgroup,\n> and that the point doesn't have a small order.\n\n* `p` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n\nReturns `true` or `false`\n\n#### `crypto_core_ed25519_from_uniform(p, r)`\n\nMaps a `crypto_core_ed25519_UNIFORMBYTES` bytes vector (usually the output of\na hash function) to a a valid curve point and stores its compressed\nrepresentation in `p`.\n\nThe point is guaranteed to be on the main subgroup.\n\n* `p` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n* `r` must be `Buffer` of at least `crypto_core_ed25519_UNIFORMBYTES` bytes\n\n#### `crypto_scalarmult_ed25519(q, n, p)`\n\nMultiply point `p` by scalar `n` and store its compressed representation in `q`.\n\n* `q` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n* `n` must be `Buffer` of at least `crypto_scalarmult_ed25519_SCALARBYTES` bytes\n* `p` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n\nNote this function will throw if `n` is zero or `p` is an invalid curve point.\n\n#### `crypto_scalarmult_ed25519_base(q, n)`\n\nMultiply the basepoint by scalar `n` and store its compressed representation in\n`q`. Note that `n` will be clamped.\n\n* `q` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n* `n` must be `Buffer` of at least `crypto_scalarmult_ed25519_SCALARBYTES` bytes\n\nNote this function will throw if `n` is zero\n\n#### `crypto_scalarmult_ed25519_noclamp(q, n, p)`\n\nMultiply point `p` by scalar `n` and store its compressed representation in `q`.\nThis version does not clamp.\n\n* `q` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n* `n` must be `Buffer` of at least `crypto_scalarmult_ed25519_SCALARBYTES` bytes\n* `p` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n\nNote this function will throw if `n` is zero or `p` is an invalid curve point.\n\n#### `crypto_scalarmult_ed25519_base_noclamp(q, n)`\n\nMultiply the basepoint by scalar `n` and store its compressed representation in\n`q`. This version does not clamp.\n\n* `q` must be `Buffer` of at least `crypto_scalarmult_ed25519_BYTES` bytes\n* `n` must be `Buffer` of at least `crypto_scalarmult_ed25519_SCALARBYTES` bytes\n\nNote this function will throw if `n` is zero\n\n#### `crypto_core_ed25519_add(r, p, q)`\n\nAdd point `q` to `p`, storing the result to `r`.\n\n* `r` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n* `p` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n* `q` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n\nWill throw if `p`, `q` are not valid curve points\n\n#### `crypto_core_ed25519_sub(r, p, q)`\n\nSubtract point `q` to `p`, storing the result to `r`.\n\n* `r` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n* `p` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n* `q` must be `Buffer` of at least `crypto_core_ed25519_BYTES` bytes\n\nWill throw if `p`, `q` are not valid curve points\n\n#### `crypto_core_ed25519_scalar_random(r)`\n\nGenerate random scalar in `]0..L[`, storing it in `r`.\n\n* `r` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_reduce(r, s)`\n\nReduce `s mod L`, storing it in `r`.\n\n* `r` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `s` must be `Buffer` of at least `crypto_core_ed25519_NONREDUCEDSCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_invert(recip, s)`\n\nFind `recip` such that `s * recip = 1 (mod L)`, storing it in `recip`.\n\n* `recip` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `s` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_negate(neg, s)`\n\nFind `neg` such that `s + neg = 0 (mod L)`, storing it in `recip`.\n\n* `recip` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `s` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_complement(comp, s)`\n\nFind `comp` such that `s + comp = 1 (mod L)`, storing it in `recip`.\n\n* `comp` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `s` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_add(z, x, y)`\n\nAdd `x` and `y` such that `x + y = z (mod L)`, storing it in `z`.\n\n* `x` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `y` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `z` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n#### `crypto_core_ed25519_scalar_sub(z, x, y)`\n\nSubtract `x` and `y` such that `x - y = z (mod L)`, storing it in `z`.\n\n* `x` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `y` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n* `z` must be `Buffer` of at least `crypto_core_ed25519_SCALARBYTES` bytes\n\n### Short hashes\n\nBindings for the crypto_shorthash API.\n[See the libsodium crypto_shorthash docs for more information](https://download.libsodium.org/doc/hashing/short-input_hashing).\n\n#### `crypto_shorthash(output, input, key)`\n\nHash a value to a short hash based on a key.\n\n* `output` should be a buffer of length `crypto_shorthash_BYTES`.\n* `input` should be a buffer of any size.\n* `key` should be a buffer of length `crypto_shorthash_KEYBYTES`.\n\nThe generated short hash is stored in `output`.\n\n### Key derivation\n\nBindings for the crypto_kdf API.\n[See the libsodium crypto_kdf docs for more information](https://download.libsodium.org/doc/key_derivation/).\n\n#### `crypto_kdf_keygen(key)`\n\nGenerate a new master key.\n\n* `key` should be a buffer of length `crypto_kdf_KEYBYTES`\n\n#### `crypto_kdf_derive_from_key(subkey, subkeyId, context, key)`\n\nDerive a new key from a master key.\n\n* `subkey` should be a buffer between `crypto_kdf_BYTES_MIN` and `crypto_kdf_BYTES_MAX`.\n* `subkeyId` should be an integer.\n* `context` should be a buffer of length `crypto_kdf_CONTEXTBYTES`\n* `key` should by a buffer of length `crypto_kdf_KEYBYTES`\n\n### SHA\n\n#### `crypto_hash_sha256(output, input)`\n\nHash a value to a short hash based on a key.\n\n* `output` should be a buffer of length `crypto_hash_sha256_BYTES`.\n* `input` should be a buffer of any size.\n\nThe generated short hash is stored in `output`.\n\n#### `var instance = crypto_hash_sha256_instance()`\n\nCreate an instance that has stream of input data to sha256.\n\n#### `instance.update(input)`\n\nUpdate the instance with a new piece of data.\n\n* `input` should be a buffer of any size.\n\n#### `instance.final(output)`\n\nFinalize the instance.\n\n* `output` should be a buffer of length `crypto_hash_sha256_BYTES`.\n\nThe generated hash is stored in `output`.\n\n#### `crypto_hash_sha512(output, input)`\n\nHash a value to a short hash based on a key.\n\n* `output` should be a buffer of length `crypto_hash_sha512_BYTES`.\n* `input` should be a buffer of any size.\n\nThe generated short hash is stored in `output`.\n\n#### `var instance = crypto_hash_sha512_instance()`\n\nCreate an instance that has stream of input data to sha512.\n\n#### `instance.update(input)`\n\nUpdate the instance with a new piece of data.\n\n* `input` should be a buffer of any size.\n\n#### `instance.final(output)`\n\nFinalize the instance.\n\n* `output` should be a buffer of length `crypto_hash_sha512_BYTES`.\n\nThe generated hash is stored in `output`.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_id":"sodium-native@2.4.6-rc","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Ikxarmey4WjFjI1VNErX+gYVrqe7dlVMDKWkvFkLeGgE5ppBK8SMuyTL0RnN8KOf0Fu3+HGVlmDy8d8EIa+GnA==","shasum":"22036a1b5fa48957c76c23f232ac621f64508034","tarball":"http://registry-npm.ywwl.com/sodium-native/download/sodium-native-2.4.6-rc.tgz","fileCount":715,"unpackedSize":35851310,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdSn7uCRA9TVsSAnZWagAAfNEQAIUEWZg/stZdSWiJKX5S\nHAC1qol0/Jxl946crpb9JIDsTcfMEM9SDldezSEMNvg/iwXg7eWusMr/LuXm\n+IhV6M1I+3SJLEhkzDwvWclyGWN56QTcbokWIopmpJowkEz4AcYzeAKIS7Od\n3ZF+0N8Kge3zZ1LdaFFyxqZkHfmkaOcRrZIpREDdS0yAjyKPU/rhZwAjzHqw\newoU3HshBAmkk1w3HOFxeQE3Axndbhec1Vy09Bg566GUexJrf6TaeCXGffqZ\nIvUqDxYkEfh22zpEe2ZtMRBYbAX/XQrF3RGAPivomNdADKAZtAIqJaGzfdDS\n9Wp/qyLkytYqgkGk+nQN1UvAvMGC6Mno2EvyY+Zca0r+x5hXBpX9EAEArkGz\neGL27J7koa2y7X+m1WzWRTkrveFv3AUFTHhbtiOrR2sNtFVu9e6gEtsLam89\nl0LzUQp3Cd5zVHz6ZU3ctxLFhvCTu2zzpDAPzBu76LLVy/B+gNqJNthTnUrU\nZkiK8cp7ytkucEioJJKbVFJqn9NMOsv8cs5dHS00jdGMY00ERK0aSBIteBmH\n+4gx8mUwVP3oigMrz2/Mq8aSpxDIC01XUnREFdN/U6qLQcQli+mLQFFhFHtP\nSKvfU/9QI6MDLBD97bvLeo5Z9nSmEgZhEjmDbzp4AdqYhWNTjWeUiCUR8U63\nESJj\r\n=yDme\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3tHDUukS5ojeaf9S0AlvhBUkXpAdLI8YsEQutd8/ufAIgBTscGIjMHIdbF1YoWKrRQ1KuflJ6Un5sAsk9rciPxJc="}],"size":12090118,"noattachment":false,"key":"/sodium-native/-/sodium-native-2.4.6-rc.tgz"},"maintainers":[{"email":"github@tixz.dk","name":"emilbayes"},{"email":"mathiasbuus@gmail.com","name":"mafintosh"}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sodium-native_2.4.6-rc_1565163245239_0.3676839196204975"},"_hasShrinkwrap":false,"publish_time":1565163246170,"_cnpm_publish_time":1565163246170,"dist-tags":{"latest":"5.2.0"}}