zkBob / libzkbob-rs

Apache License 2.0
1 stars 3 forks source link

Automatic backups #43

Open r0wdy1 opened 1 year ago

r0wdy1 commented 1 year ago

In order to allow our users to migrate seamlessly between devices w/o redundant sync we should introduce automatic opt-in backup service, that would encrypt and store client state backup in a cloud storage ( preferably a decentralized one)

Saving backups

  1. Client init method must accept a new optional parameter automaticBackup : bool
  2. If automaticBackup is set , than after every successful transaction or receiving a shielded note or every X indices a backup procedure must be called, which performs following steps:
    1. collects all of the known unspent notes, account , latest index to a single struct ( using Borsh)
    2. serializes, encrypts the data ( the same ChaChaPoly in AEAD mode) using eta
    3. calls proxy RPC to store the data with some retry policy. A hash of eta can be used as identifier

Sync from backup

Whenever a user logs in and client initializes, it should call the storage proxy service to check whether a backup for this user is available. If a backup is available and was successfully decrypted, then the client state is populated from decrypted response

Why proxy?

The proxy is needed to abstract storage integration logic away from client code. That would allow to migrate from eg S3 to IPFS or StorJ without any changes on the client side.

maikReal commented 1 year ago

Connected with: