From ab3b23f1003bc374d65f512873c9a6165a17c062 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 19 May 2022 16:07:30 +1000 Subject: [PATCH] Remove Buffer from symmetric.ts --- src/lib/waku_message/symmetric.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/waku_message/symmetric.ts b/src/lib/waku_message/symmetric.ts index 9d2890a2a4..f6337fe56b 100644 --- a/src/lib/waku_message/symmetric.ts +++ b/src/lib/waku_message/symmetric.ts @@ -7,29 +7,29 @@ export const TagSize = 16; const Algorithm = { name: "AES-GCM", length: 128 }; export async function encrypt( - iv: Buffer | Uint8Array, - key: Buffer, - clearText: Buffer -): Promise { + iv: Uint8Array, + key: Uint8Array, + clearText: Uint8Array +): Promise { return getSubtle() .importKey("raw", key, Algorithm, false, ["encrypt"]) .then((cryptoKey) => getSubtle().encrypt({ iv, ...Algorithm }, cryptoKey, clearText) ) - .then(Buffer.from); + .then((cipher) => new Uint8Array(cipher)); } export async function decrypt( - iv: Buffer, - key: Buffer, - cipherText: Buffer -): Promise { + iv: Uint8Array, + key: Uint8Array, + cipherText: Uint8Array +): Promise { return getSubtle() .importKey("raw", key, Algorithm, false, ["decrypt"]) .then((cryptoKey) => getSubtle().decrypt({ iv, ...Algorithm }, cryptoKey, cipherText) ) - .then(Buffer.from); + .then((clear) => new Uint8Array(clear)); } export function generateIv(): Uint8Array {