diff --git a/native/qr-code/qr-code-screen.react.js b/native/qr-code/qr-code-screen.react.js --- a/native/qr-code/qr-code-screen.react.js +++ b/native/qr-code/qr-code-screen.react.js @@ -10,14 +10,13 @@ import type { NavigationRoute } from '../navigation/route-names.js'; import { useStyles } from '../themes/colors.js'; import * as AES from '../utils/aes-crypto-module.js'; +import { getContentSigningKey } from '../utils/crypto-utils.js'; type QRCodeScreenProps = { +navigation: QRCodeSignInNavigationProp<'QRCodeScreen'>, +route: NavigationRoute<'QRCodeScreen'>, }; -const defaultDeviceEd25519Key = 'device_ed25519_key'; - // eslint-disable-next-line no-unused-vars function QRCodeScreen(props: QRCodeScreenProps): React.Node { const [qrCodeValue, setQrCodeValue] = React.useState(); @@ -25,7 +24,9 @@ const generateQRCode = React.useCallback(async () => { try { const aes256Key: Uint8Array = await AES.generateKey(); - const url = qrCodeLinkURL(aes256Key, defaultDeviceEd25519Key); + const ed25519Key: string = await getContentSigningKey(); + + const url = qrCodeLinkURL(aes256Key, ed25519Key); setQrCodeValue(url); } catch (err) { console.error('Failed to generate QR Code:', err); diff --git a/web/account/qr-code-login.react.js b/web/account/qr-code-login.react.js --- a/web/account/qr-code-login.react.js +++ b/web/account/qr-code-login.react.js @@ -7,21 +7,27 @@ import css from './qr-code-login.css'; import { generateKey } from '../media/aes-crypto-utils.js'; - -const defaultDeviceEd25519Key = 'device_ed25519_key'; +import { useSelector } from '../redux/redux-utils.js'; function QrCodeLogin(): React.Node { const [qrCodeValue, setQrCodeValue] = React.useState(); + const ed25519Key = useSelector( + state => state.cryptoStore.primaryIdentityKeys?.ed25519, + ); const generateQRCode = React.useCallback(async () => { try { + if (!ed25519Key) { + return; + } + const aes256Key: Uint8Array = await generateKey(); - const url = qrCodeLinkURL(aes256Key, defaultDeviceEd25519Key); + const url = qrCodeLinkURL(aes256Key, ed25519Key); setQrCodeValue(url); } catch (err) { console.error('Failed to generate QR Code:', err); } - }, []); + }, [ed25519Key]); React.useEffect(() => { generateQRCode();