diff --git a/native/backup/encryption.js b/native/backup/encryption.js new file mode 100644 --- /dev/null +++ b/native/backup/encryption.js @@ -0,0 +1,16 @@ +// @flow + +import { fetchNativeKeychainCredentials } from '../account/native-credentials.js'; +import { commCoreModule } from '../native-modules.js'; + +async function getBackupKey(backupID: string): Promise { + const nativeCredentials = await fetchNativeKeychainCredentials(); + if (!nativeCredentials) { + throw new Error('Native credentials are missing'); + } + const { password } = nativeCredentials; + const backupKey = await commCoreModule.computeBackupKey(password, backupID); + return new Uint8Array(backupKey); +} + +export { getBackupKey };