Skip to content

Commit

Permalink
using device keys for shared key negotiation solves an encryption fai…
Browse files Browse the repository at this point in the history
…lure (and the newly added test case)
  • Loading branch information
michaelkamphausen committed Nov 29, 2024
1 parent 80c64dc commit f4fe317
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/auth/src/connection/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ export class Connection extends EventEmitter<ConnectionEvents> {
// SHARED SECRET NEGOTIATION

sendSeed: assign(({ context }) => {
const { user, peer, seed = randomKeyBytes() } = context
const { device, theirDevice, seed = randomKeyBytes() } = context

const recipientPublicKey = peer!.keys.encryption
const senderSecretKey = user!.keys.encryption.secretKey
const recipientPublicKey = theirDevice!.keys.encryption
const senderSecretKey = device.keys.encryption.secretKey

this.#log(`encrypting seed with key ${recipientPublicKey}`)
const encryptedSeed = asymmetric.encryptBytes({
Expand All @@ -350,10 +350,10 @@ export class Connection extends EventEmitter<ConnectionEvents> {
deriveSharedKey: assign(({ context, event }) => {
assertEvent(event, 'SEED')
const { encryptedSeed } = event.payload
const { seed, user, peer } = context
const { seed, device, theirDevice } = context
const cipher = encryptedSeed
const senderPublicKey = peer!.keys.encryption
const recipientSecretKey = user!.keys.encryption.secretKey
const senderPublicKey = theirDevice!.keys.encryption
const recipientSecretKey = device.keys.encryption.secretKey

// decrypt the seed they sent
try {
Expand Down

0 comments on commit f4fe317

Please sign in to comment.