From 09aa462fd0fcfcf2fa3d03d3ad2e70a95ca82310 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:50:29 -0700 Subject: [PATCH] use the lowercased spaceId as the key phrase for deriving the key and iv (#621) --- packages/sdk/src/client.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/sdk/src/client.ts b/packages/sdk/src/client.ts index 596f8c7ab..884d63b78 100644 --- a/packages/sdk/src/client.ts +++ b/packages/sdk/src/client.ts @@ -855,7 +855,8 @@ export class Client this.logCall('setSpaceImage', spaceStreamId, mediaStreamId, info) // create the chunked media to be added - const spaceId = contractAddressFromSpaceId(spaceStreamId) + const spaceAddress = contractAddressFromSpaceId(spaceStreamId) + const context = spaceAddress.toLowerCase() const chunkedMedia = new ChunkedMedia({ info, streamId: mediaStreamId, @@ -863,13 +864,14 @@ export class Client encryption: { case: 'derived', value: { - context: spaceId, + context, }, }, }) // encrypt the chunked media - const { key, iv } = await deriveKeyAndIV(spaceId) + // use the lowercased spaceId as the key phrase + const { key, iv } = await deriveKeyAndIV(context) const { ciphertext } = await encryptAESGCM(chunkedMedia.toBinary(), key, iv) const encryptedData = new EncryptedData({ ciphertext: uint8ArrayToBase64(ciphertext),