matrix-org / matrix-js-sdk

Matrix Client-Server SDK for JavaScript
Apache License 2.0
1.61k stars 589 forks source link

Improve documentation of Rust crypto #4132

Closed richvdh closed 4 days ago

richvdh commented 7 months ago
richvdh commented 7 months ago

We might want to make initCrypto an alias for initRustCrypto first, to save updating the docs twice

t3chguy commented 7 months ago

We might want to make initCrypto an alias for initRustCrypto first, to save updating the docs twice

Rust Crypto hasn't reached feature parity yet, so I'm against this.

richvdh commented 7 months ago

Rust Crypto hasn't reached feature parity yet, so I'm against this.

We're planning to remove the old code soon, rather than maintaining two crypto stacks indefinitely. If you're aware of any specific blockers, could you raise them as issues so we can prioritise them?

t3chguy commented 7 months ago

One that has massively impacted me personally due to switching HS:

matthintosh commented 6 months ago

Hi ! Any news about this issue ? I have multiple blocking point with rust crypto like "One time key signed_curve25519:AAAAAAAAAA8 already exists" and unable to decrypt message. Maybe I'm missing something on client creation side or whatever but the documentation related to e2ee is very poor actually and the README explain that the old fashionned way for encryption is deprecated. Any help is welcome. Thank you !

saul-jb commented 1 month ago

I have multiple blocking point with rust crypto like "One time key signed_curve25519:AAAAAAAAAA8 already exists" and unable to decrypt message.

Just been through the headache of updating matrix-js-sdk and getting e2e encryption working again with the rust crypto... I was running into that error when I had disabled indexedDB in initRustCrypto:

const client = sdk.createClient({
  // ...
  cryptoStore: new LocalStorageCryptoStore(path)
})

await client.initRustCrypto({ useIndexedDB: false })

To fix this you need to enabled indexedDB and provide an implementation as your crypto store using: IndexedDBCryptoStore, i.e. :

/**
 * This part is to load an implementation of indexedDB in nodejs:
 */

// @ts-expect-error Missing types.
import dbManager from 'node-indexeddb/dbManager'
async function loadModule (): Promise<void> {
  await dbManager.loadCache().catch(console.error)

  // @ts-expect-error Missing types.
  await import('node-indexeddb/auto')
}
await loadModule()
/**
 * This part is to use the indexedDB
 */
const idbFactory = new IDBFactory()

const client = sdk.createClient({
  // ...
  cryptoStore: new IndexedDBCryptoStore(idbFactory, path)
})

await client.initRustCrypto()