import type { LibDemos } from "@libdemos"; /** * Decrypts a box with additional data using the * crypto_aead_chacha20poly1305_ietf_decrypt function from libsodium and * a provided symmetric key in Uint8Array(32) format. * The encrypted box is a Uint8Array[nonce 16 || encrypted_data || auth tag 12]. * * If you need to perform bulk decryptions with predictable box * and additional data sizes then it will be more efficient to preload * the wasm module and reuse it as follows: * * ```ts * const messageLen = message.length; * const additionalLen = additionalData.length; * * const wasmMemory = demosMemory.decryptSymmetricKeyMemory(messageLen, additionalLen); * const wasmModule = await demosMethodsModule({ wasmMemory }); * ``` * * If not all boxes and additional data are equal, you can always just use * the largest Uint8Arrays as inputs. * * ```ts * import demos from \"@deliberative/crypto\" * * const message = new Uint8Array(128).fill(1); * const symmetricKey = new Uint8Array(32).fill(3); * const additionalData = new Uint8Array(64).fill(2); * * const box = await demos.encryptSymmetricKey( * message, * symmetricKey, * additionalData * ); * const decrypted = await demos.decryptSymmetricKey( * box, * symmetricKey, * additionalData * ); * * \/\/ message should be equal to decrypted. * ``` * * @param encrypted - the encrypted box including nonce and auth tag * @param symmetricKey - the precomputed symmetric key * @param additionalData - the additional data for aead * @param module - wasm module in case of bulk decryptions * * @returns The decrypted message */ declare const decryptSymmetric: (encrypted: Uint8Array, symmetricKey: Uint8Array, additionalData: Uint8Array, module?: LibDemos) => Promise; export default decryptSymmetric; //# sourceMappingURL=decryptSymmetric.d.ts.map