Skip to main content
Allow customers to use their existing Firebase Authentication to authenticate into a secure enclave that holds the encryption key for the user. The Portal SDK leverages Firebase ID tokens to securely store and retrieve encryption keys from the secure enclave.

How it works

  1. Your app signs the user in with Firebase Auth (Email/Password, Google Sign-In, Phone, or any other Firebase Auth provider).
  2. You configure the Portal SDK with a callback that returns a fresh Firebase ID token.
  3. During backup, the SDK encrypts the client backup share and stores the encryption key in the secure enclave, authenticated by the Firebase ID token.
  4. During recovery, the SDK retrieves the encryption key from the secure enclave using the same authentication, then decrypts the backup share to restore the wallet.

Security model

The secure enclave is Portal’s Trustless Backup Service (TBS) at backup.web.portalhq.io. Every Portal SDK calls it directly from the user’s device. The only secret it stores is the encryption key for each client’s backup. It never stores key shares, encrypted backups, or Firebase tokens. Alongside the key it keeps the Portal client ID and a hash of the bound Firebase UID (see below). The encryption key is a random 256-bit AES-GCM key generated on the device for each backup. Portal’s main API never receives the key, and the Trustless Backup Service never receives the encrypted share.

How requests are authorized

Every request to the Trustless Backup Service carries two credentials, and both must be valid:
  1. The Portal client credential (Client API Key or Client Session Token) identifies the Portal client.
  2. The Firebase ID token identifies the user. The service verifies its signature against Google’s public keys, checks that it has not expired, and requires its issuer and audience to match the Firebase project ID you registered for the environment.
On the first successful request, the service binds that Firebase user to the Portal client and stores a SHA-256 hash of the Firebase UID, never the raw UID. After that, requests for the client from any other Firebase user are rejected. A Portal credential alone cannot read the key, and neither can a valid Firebase token for a different user.

How the key is protected

  • The Trustless Backup Service runs in AWS Nitro Enclaves, on infrastructure separate from Portal’s main API.
  • TLS terminates inside the enclave.
  • Stored keys are envelope-encrypted with AWS KMS, and the key policy only allows decryption from an attested enclave running Portal’s approved build.

Integration requirements

  • Keep one Portal client per user. The key is bound to the Portal client. When a user recovers on a new device, authenticate as their existing client instead of creating a new one.
  • Keep the Firebase UID stable. If a user signs in with a provider that creates a new Firebase user instead of linking to the existing account, recovery fails with 403. Use Firebase account linking for users with more than one sign-in provider.
  • Backing up again replaces the key. Each backup stores a new key for the client.
  • Firebase backup keys cannot be deleted. The Trustless Backup Service has no delete operation.
  • Register your Firebase project in every environment you use, including production.

Errors

Prerequisites

  1. A Firebase project with Firebase Authentication enabled.
  2. At least one sign-in provider configured in Firebase Auth (Email/Password, Google Sign-In, Apple Sign-In, etc.).
  3. Your Firebase project registered with Portal (see below).

Register your Firebase project with Portal

You must register your Firebase project with Portal so that the secure enclave can validate your users’ Firebase ID tokens.
  1. Go to the Portal Dashboard.
  2. Navigate to Configuration > Firebase Auth.
  3. In the Firebase Backup Authentication Config section, enter your Firebase Project ID and save.
You can also register the JWT provider programmatically via the Custodian API:

Add Firebase to your app

If you have not already set up Firebase in your iOS app, follow the Firebase iOS setup guide. At a minimum, you need to:
  1. Add your iOS app in the Firebase Console.
  2. Download the GoogleService-Info.plist file and add it to your Xcode project.
  3. Add the FirebaseAuth dependency via Swift Package Manager or CocoaPods.
  4. Call FirebaseApp.configure() in your AppDelegate or app entry point.

Supported platforms

Firebase Auth Backup is currently available on: