CRITICAL story-encrypted-assignment-dispatch-coordinator-004 8 pts
8
Story Points
Critical
Priority
Encrypted Assignment Dispatch
Feature

User Story

As a user
I want my encryption key pair to be automatically generated and securely stored on my device the first time I log in with BankID, so that I can send and receive encrypted assignments without any manual cryptographic setup
So that So that the encryption system is available immediately after authentication without requiring technical knowledge from the user, while ensuring private keys never leave the device

Acceptance Criteria

  • Given the user completes BankID authentication for the first time, when the session is established, then an X25519 key pair is generated and the private key is stored in the device secure enclave without any user interaction required
  • Given key generation succeeds, when the public key is uploaded to Supabase, then the user's profile record is updated with the public key and is available for lookup by coordinators
  • Given the app is reinstalled and secure storage is cleared, when the user logs in with BankID again, then they are prompted to re-derive their key pair and the private key is restored to the secure enclave
  • Given key generation fails due to a hardware security module error, when the login flow continues, then the user is informed that encrypted messaging is unavailable and is prompted to retry on a compatible device
  • Given the key pair already exists on the device, when the user logs in again, then no new key pair is generated and the existing keys are used
  • Given a user's public key exists in Supabase, when a coordinator addresses an encrypted assignment to that user, then the correct public key is retrieved and used for encryption

Business Value

Key initialization is the foundational prerequisite for all encrypted dispatch functionality. Without it, neither sending nor receiving encrypted assignments is possible. Tying key derivation to BankID identity provides a legally auditable ownership chain, meeting the authentication strength requirements for handling sensitive personal data under GDPR. Automatic initialization eliminates adoption friction for non-technical volunteer users.