Skip to content

platform-wallet-storage: keep an exported invitation key from being offered again after a deleted row, a power loss or a backup restore #6324

Backlog

Description

@Claudius-Maginificent

TL;DR: With the SQLite store, a wallet can hand out an invitation key it already exported in three storage situations: a deleted key record, a power loss right after the export, or a restore from an older backup. Tracks the protections the SQLite store still needs.

User story

As a wallet user sending identity invitations, I want every invitation to use a key that was never exported before, to achieve invitations that nobody holding an older invitation can claim.

Scenario

Base flow

  1. The wallet uses the SQLite store (platform-wallet-storage), which advertises WALLET_RESTORE since feat(wallet-storage)!: restore complete Core wallet snapshots from SQLite #5210, so invitation creation is enabled on it.
  2. The wallet exports a one-time funding key in an invitation and records it as used.
  3. Later the wallet loads from that store again.

Actual behavior

The key can be offered again for a new invitation when:

  1. Deleted record. The record of the used key is deleted from core_address_pool (for example the highest stored row). restore_pools audits only rows that still exist, so the index comes back available. fix(platform-wallet): keep pre-derived lost funding rows ineligible after restart #6035 marks missing rows below the highest persisted row on the host restore path, and fix(platform-wallet): keep invitation issuance floor across reloads #6102 keeps a floor after detected gap damage; neither covers SQLite's restore_pools or a deleted tail row.
  2. Power loss. The default configuration (Synchronous::Normal with WAL) survives an app crash but not an OS crash or power loss, so the write marking the key used can be lost after the invitation left the device.
  3. Older backup. Restoring an intact SQLite backup taken before the invitation brings back a store in which the key was never used; nothing in the rows shows the rollback.

Expected behavior

An exported invitation key is never offered again, whatever happens to the store afterwards.

Detailed discussion

🤖 Co-authored by Claudius the Magnificent AI Agent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions