Skip to content
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

ElementR: Add rust-crypto#createRecoveryKeyFromPassphrase implementation #3472

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions spec/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ limitations under the License.
*/

import DOMException from "domexception";
import * as crypto from "crypto";

global.DOMException = DOMException as typeof global.DOMException;
// Set node crypto into global.crypto
// Needed in `CryptoApi#createRecoveryKeyFromPassphrase` and `crypto/crypto.ts`
global.crypto = crypto.webcrypto as typeof global.crypto;

jest.mock("../src/http-api/utils", () => ({
...jest.requireActual("../src/http-api/utils"),
Expand Down
3 changes: 2 additions & 1 deletion src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { CrossSigningIdentity } from "./CrossSigningIdentity";
import { secretStorageContainsCrossSigningKeys } from "./secret-storage";
import { keyFromPassphrase } from "../crypto/key_passphrase";
import { encodeRecoveryKey } from "../crypto/recoverykey";
import { crypto } from "../crypto/crypto";
florianduros marked this conversation as resolved.
Show resolved Hide resolved

/**
* An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.
Expand Down Expand Up @@ -426,7 +427,7 @@ export class RustCrypto implements CryptoBackend {
} else {
// Using the navigator crypto API to generate the private key
privateKey = new Uint8Array(32);
global.crypto.getRandomValues(privateKey);
crypto.getRandomValues(privateKey);
}

const encodedPrivateKey = encodeRecoveryKey(privateKey);
Expand Down