Asymmetric Encryption Key Pair Provisioned at User Onboarding
During the onboarding flow, after successful BankID or Vipps authentication, the Key Management Service generates an asymmetric key pair using device-native APIs. The private key is persisted exclusively in Flutter Secure Storage (OS secure enclave) and never transmitted anywhere. The public key is registered in Supabase against the user's account, making it available for coordinators to encrypt inbound assignments. The user sees no friction — the key generation happens transparently in a background Isolate. If a user reinstalls the app or switches devices, a key re-provisioning flow is triggered.
User Story
Acceptance Criteria
- Given a new user completes BankID or Vipps authentication during onboarding, when the onboarding flow completes, then an asymmetric key pair has been generated and the public key is registered in Supabase without any user action required
- Given the private key is generated, when it is stored, then it is persisted exclusively in Flutter Secure Storage and is never included in any network request or backup
- Given the public key registration completes, when a coordinator attempts to send an encrypted assignment to this user, then the public key is retrievable by the Task Encryption Service for payload encryption
- Given the user reinstalls the app or uses a new device, when they re-authenticate, then a new key pair is generated and the public key in Supabase is updated, with previous assignments remaining unreadable on the old device
- Given key generation is running, when it executes in a Flutter Isolate, then the onboarding UI remains fully responsive with no visible lag
Business Value
The entire encrypted assignment system depends on each user having a valid key pair. Without this story, no encrypted assignment can be sent or received. Generating keys transparently at onboarding eliminates user friction while enforcing the security model where private keys never leave the device — a core architectural guarantee required for GDPR-compliant handling of medical and personal data.
Components
- Key Management Service service
- Encryption Infrastructure infrastructure