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 @@ -7,6 +7,7 @@ import { qrCodeLinkUrl } from 'lib/facts/links.js'; import type { QRCodeSignInNavigationProp } from './qr-code-sign-in-navigator.react.js'; +import { commCoreModule } from '../native-modules.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useStyles } from '../themes/colors.js'; import * as AES from '../utils/aes-crypto-module.js'; @@ -16,8 +17,6 @@ +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,13 @@ React.useEffect(() => { (async () => { const aes256Key: Uint8Array = await AES.generateKey(); - const url = qrCodeLinkUrl(aes256Key, defaultDeviceEd25519Key); + + await commCoreModule.initializeCryptoAccount(); + const { + primaryIdentityPublicKeys: { ed25519: ed25519Key }, + } = await commCoreModule.getUserPublicKey(); + + const url = qrCodeLinkUrl(aes256Key, ed25519Key); setQrCodeValue(url); })(); }, []); 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,19 +7,25 @@ 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, + ); React.useEffect(() => { (async () => { + if (!ed25519Key) { + return; + } + const aes256Key: Uint8Array = await generateKey(); - const url = qrCodeLinkUrl(aes256Key, defaultDeviceEd25519Key); + const url = qrCodeLinkUrl(aes256Key, ed25519Key); setQrCodeValue(url); })(); - }, []); + }, [ed25519Key]); return (