From 181ba489be91bbe770601acdc144d184b46c2886 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 19 May 2022 16:21:09 +1000 Subject: [PATCH] Remove `Buffer` from `encrypt*` --- src/lib/waku_message/version_1.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/waku_message/version_1.ts b/src/lib/waku_message/version_1.ts index 600316f5b4..6407b2a00d 100644 --- a/src/lib/waku_message/version_1.ts +++ b/src/lib/waku_message/version_1.ts @@ -118,10 +118,10 @@ export function clearDecode( * @internal */ export async function encryptAsymmetric( - data: Uint8Array | Buffer, - publicKey: Uint8Array | Buffer | string + data: Uint8Array, + publicKey: Uint8Array | string ): Promise { - return ecies.encrypt(Buffer.from(hexToBytes(publicKey)), Buffer.from(data)); + return ecies.encrypt(hexToBytes(publicKey), data); } /** @@ -147,18 +147,14 @@ export async function decryptAsymmetric( * @internal */ export async function encryptSymmetric( - data: Uint8Array | Buffer, - key: Uint8Array | Buffer | string + data: Uint8Array, + key: Uint8Array | string ): Promise { const iv = symmetric.generateIv(); // Returns `cipher | tag` - const cipher = await symmetric.encrypt( - iv, - Buffer.from(hexToBytes(key)), - Buffer.from(data) - ); - return Buffer.concat([cipher, Buffer.from(iv)]); + const cipher = await symmetric.encrypt(iv, hexToBytes(key), data); + return concat([cipher, iv]); } /**