key doesn't need to be optional parameter as its always passed

This commit is contained in:
Abhinav 2023-02-27 21:08:31 +05:30
parent 01cc8ffe4d
commit 721f21cee8

View file

@ -79,12 +79,10 @@ export async function decryptChunk(data: Uint8Array, pullState: StateAddress) {
return { decryptedData: pullResult.message, newTag }; return { decryptedData: pullResult.message, newTag };
} }
export async function encryptChaChaOneShot(data: Uint8Array, key?: string) { export async function encryptChaChaOneShot(data: Uint8Array, key: string) {
await sodium.ready; await sodium.ready;
const uintkey: Uint8Array = key const uintkey: Uint8Array = await fromB64(key);
? await fromB64(key)
: sodium.crypto_secretstream_xchacha20poly1305_keygen();
const initPushResult = const initPushResult =
sodium.crypto_secretstream_xchacha20poly1305_init_push(uintkey); sodium.crypto_secretstream_xchacha20poly1305_init_push(uintkey);
const [pushState, header] = [initPushResult.state, initPushResult.header]; const [pushState, header] = [initPushResult.state, initPushResult.header];