Skip to content

Commit

Permalink
use the lowercased spaceId as the key phrase for deriving the key and…
Browse files Browse the repository at this point in the history
… iv (#621)
  • Loading branch information
tak-hntlabs authored Aug 5, 2024
1 parent e65c8ef commit 09aa462
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,21 +855,23 @@ 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,
thumbnail,
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),
Expand Down

0 comments on commit 09aa462

Please sign in to comment.