Closed
Description
Good afternoon,
I am writing a simple program to send encrypted messages to a matrix room.
I am currently trying to setup cross-signing, but am erroring out with
import * as sdk from "matrix-js-sdk";
import "fake-indexeddb/auto";
import bs58 from "bs58";
const recoveryKeyString = process.env.BACKUP_KEY_MATRIX
const client = sdk.createClient({
baseUrl: "https://matrix.org",
accessToken: process.env.MATRIX_ACCESS_TOKEN,
userId: process.env.MATRIX_USER,
deviceId: "frigate-server",
cryptoCallbacks: {
getSecretStorageKey: async (keys) => {
const key = sdk.Crypto.decodeRecoveryKey(recoveryKeyString);
return [Object.keys(keys.keys)[0], key];
},
},
});
await client.initRustCrypto();
client.getCrypto().bootstrapSecretStorage({
// This function will be called if a new secret storage key (aka recovery key) is needed.
// You should prompt the user to save the key somewhere, because they will need it to unlock secret storage in future.
createSecretStorageKey: async () => {
return key;
}
});
await client.getCrypto().bootstrapCrossSigning({
authUploadDeviceSigningKeys: async (makeRequest) => {
return makeRequest(authDict);
},
});
client.startClient({ initialSyncLimit: 10});
const content = {
body: "message text",
msgtype: "m.text",
};
client.getCrypto().prepareToEncrypt(process.env.MATRIX_ROOM_ID);
await client.sendEvent(process.env.MATRIX_ROOM_ID, "m.room.message", content, "", (err, res) => {
console.log(err);
});
All messages sent to the room aren't encrypted either.
The account was originally setup with Element, in which secure backup, encryption, and cross-signing were also setup.
All values provided in process.env are correct.
It is erroring out with:
bootstrapCrossSigning: starting {
setupNewCrossSigning: undefined,
olmDeviceHasMaster: false,
olmDeviceHasUserSigning: false,
olmDeviceHasSelfSigning: false,
privateKeysInSecretStorage: true
}
bootstrapCrossSigning: Cross-signing private keys not found locally, but they are available in secret storage, reading storage and caching locally
WARN matrix_sdk_crypto::store: No public identity found while importing cross-signing keys, a /keys/query needs to be done
Error: the signing key is missing from the object that signed the message
Does anybody have any input?
Kind Regards