Page MenuHomePhabricator

Introduce function to get path to a file to temporarily save backup message
AcceptedPublic

Authored by marcin on Mon, Apr 22, 11:20 AM.
Tags
None
Referenced Files
F1693380: D11714.id39353.diff
Thu, May 2, 3:13 PM
Unknown Object (File)
Thu, May 2, 1:14 AM
Unknown Object (File)
Wed, May 1, 10:24 PM
Unknown Object (File)
Mon, Apr 29, 3:01 PM
Unknown Object (File)
Sun, Apr 28, 1:39 PM
Unknown Object (File)
Fri, Apr 26, 10:30 PM
Unknown Object (File)
Fri, Apr 26, 5:34 PM
Unknown Object (File)
Tue, Apr 23, 1:50 AM
Subscribers

Details

Reviewers
kamil
bartek
Summary

The backup message content will be temporarily persisted in a file after backup creation. Then the thread responsible for backup upload will read this file and attach
its content to upload request. Finally the file will be deleted.
This diff introduces utility functions to get teh path to save this file.

Test Plan

Call this function from any native/rust code.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Two questions:

  1. Could you explain why we need backupID? The message to sign seems generic and wondering if we need a separate file for each backupID
  2. Is there an easy way to somehow unify getSIWEBackupMessagePath with getBackupUserKeysFilePath which is basically doing the same?
native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
92 ↗(On Diff #39353)

maybe something like this?

native/ios/Comm/PlatformSpecificTools.mm
130 ↗(On Diff #39353)

Could you explain why we need backupID? The message to sign seems generic and wondering if we need a separate file for each backupID

For each backupID we specify backup message that was used to encrypt backup with backup id. Theoretically we can have distinct backup message for each backup id. However your suggestion would work. The reason for that is backup message stays the same as long as SIWE user is logged in. And when the user logs out we delete entire content of backup directory anyway. So for now it is not possible for the compaction files to be encrypted with different backup message. I am not suer however if this assumption could be broken in future. I will give it some thought.

rename msgbackup to siweBackupMsg

Are we storing the backup message and its signature in an encrypted way?

Are we storing the backup message and its signature in an encrypted way?

The signature is kept in SQLite and never leaves SQLite so it is always stored in encrypted way. Backup messages resides in SQLite as well but in current design it is temporarily written to a flat file. The reason for that is the Rust thread that creates compaction is different thread than the one responsible for uploading and the system was designed in January in such a way that data necessary for upload are created and stored in files and then the other thread reads, uploads and deletes those files. Answering you question - backup message is not stored encrypted but is it data that are potentially sensitive? It is the signature that we use to encrypt backup so without the wallet this message isn't useful.

Could you explain why we need backupID? The message to sign seems generic and wondering if we need a separate file for each backupID

For each backupID we specify backup message that was used to encrypt backup with backup id. Theoretically we can have distinct backup message for each backup id. However your suggestion would work. The reason for that is backup message stays the same as long as SIWE user is logged in. And when the user logs out we delete entire content of backup directory anyway. So for now it is not possible for the compaction files to be encrypted with different backup message. I am not suer however if this assumption could be broken in future. I will give it some thought.

Thinking about it I can't see a case where not using backupID to create a path would lead to errors but I think doing so is more future proof and consistent with the way we construct temporary files for other data that we upload to backup service.

Is there an easy way to somehow unify getSIWEBackupMessagePath with getBackupUserKeysFilePath which is basically doing the same?

Let's introduce a private method that constructs path from any two strings and us it in those public methods.

Extract common logic to private function and simplify public methods.

This revision is now accepted and ready to land.Mon, Apr 29, 6:08 AM