Page MenuHomePhabricator

D9074.diff
No OneTemporary

D9074.diff

diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js
--- a/native/account/siwe-panel.react.js
+++ b/native/account/siwe-panel.react.js
@@ -18,9 +18,9 @@
type BindServerCallsParams,
} from 'lib/utils/action-utils.js';
-import { commCoreModule } from '../native-modules.js';
import { useSelector } from '../redux/redux-utils.js';
import Alert from '../utils/alert.js';
+import { getContentSigningKey } from '../utils/crypto-utils.js';
import { defaultLandingURLPrefix } from '../utils/url-utils.js';
const commSIWE = `${defaultLandingURLPrefix}/siwe`;
@@ -79,10 +79,7 @@
setNonce(response);
})(),
);
- await commCoreModule.initializeCryptoAccount();
- const {
- primaryIdentityPublicKeys: { ed25519 },
- } = await commCoreModule.getUserPublicKey();
+ const ed25519 = await getContentSigningKey();
setPrimaryIdentityPublicKey(ed25519);
})();
}, [dispatchActionPromise, getSIWENonceCall]);
diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js
--- a/native/backup/use-client-backup.js
+++ b/native/backup/use-client-backup.js
@@ -12,6 +12,7 @@
import { encryptBackup } from './encryption.js';
import { commCoreModule } from '../native-modules.js';
import { generateKey } from '../utils/aes-crypto-module.js';
+import { getContentSigningKey } from '../utils/crypto-utils.js';
type ClientBackup = {
+uploadBackupProtocol: (userData: UserData) => Promise<void>,
@@ -32,19 +33,17 @@
console.info('Start uploading backup...');
const backupDataKey = generateKey();
- await commCoreModule.initializeCryptoAccount();
- const {
- primaryIdentityPublicKeys: { ed25519 },
- } = await commCoreModule.getUserPublicKey();
+
+ const [ed25519, backupID] = await Promise.all([
+ getContentSigningKey(),
+ commCoreModule.generateRandomString(BACKUP_ID_LENGTH),
+ ]);
+
const userKeys: UserKeys = {
backupDataKey: uintArrayToHexString(backupDataKey),
ed25519,
};
- const backupID = await commCoreModule.generateRandomString(
- BACKUP_ID_LENGTH,
- );
-
const encryptedBackup = await encryptBackup({
backupID,
userKeys,
diff --git a/native/utils/crypto-utils.js b/native/utils/crypto-utils.js
--- a/native/utils/crypto-utils.js
+++ b/native/utils/crypto-utils.js
@@ -52,4 +52,12 @@
);
}
-export { useInitialNotificationsEncryptedMessage };
+async function getContentSigningKey(): Promise<string> {
+ await commCoreModule.initializeCryptoAccount();
+ const {
+ primaryIdentityPublicKeys: { ed25519 },
+ } = await commCoreModule.getUserPublicKey();
+ return ed25519;
+}
+
+export { useInitialNotificationsEncryptedMessage, getContentSigningKey };

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 10:07 PM (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586489
Default Alt Text
D9074.diff (2 KB)

Event Timeline