-
-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Public Key Mismatch When Using restoreKeyBackupWithRecoveryKey
#4173
Comments
I made it work. Here is what I found out:
Here's some code snippets for anyone who struggled with the same confusion like I did. The callback that's needed, i.e. createClient(... cryptoCallbacks: { getSecretStorageKey: getSecretStorageKey } ): const getSecretStorageKey = async (keys: { keys: Record<string, Matrix.SecretStorage.SecretStorageKeyDescriptionAesV1>; }, name: string): Promise<null | [string, Uint8Array]> => {
const defaultKeyId = await client.secretStorage.getDefaultKeyId();
// ...
// Omitted some code to check keyId match, and differentiate key names if needed
// ...
const keyBackupKey = client.keyBackupKeyFromRecoveryKey(recoveryKey);
return [defaultKeyId, keyBackupKey];
} Then, these are the things I needed: await crypto?.bootstrapCrossSigning({}); // Do this after making sure CryptoApi.isSecretStorageReady() == true
await client.startClient();
await crypto?.crossSignDevice(deviceId); // You should see the request to .../keys/signatures/upload endpoint in logs Leaving the issue open for a bit more in case anyone wants to correct something I did wrong. :) |
Thanks a lot for posting part of the solution. Would you be able to share the fully working code by any chance? I am not able to reproduce what you describe as the solution. Thanks in advance @xiaoyue. |
I'm trying to enable E2EE and verify a device for a bot account in Node.js. On the Element Web client, I can log into the bot account with password, and when there's no other verified devices/sessions, it asked me to use the account security key to verify the session.
I tried to do this similarly for my Node.js bot: let it login with credentials, and assume no other device/session is verified, I want to use the security key to verify the current device and session.
When I trace the source code for Element Web and matrix-react-sdk, I found that behind the security key input dialog, the MatrixClient.restoreKeyBackupWithRecoveryKey() function from matrix-js-sdk was used. So I attempted to do the same. However, I am getting a "getBackupDecryptor key mismatch" error. From the source code, it seems the recovery key was decrypted successfully, and when generating the public key it didn't match. However, the same key for this account can be used in Element Web (supposedly through the same function) without issue. I'm definitely doing something wrong here, but I don't know what. Can someone point out what I missed?
The text was updated successfully, but these errors were encountered: