Authentication
Authentication is a singleauthenticate() call that connects the user’s wallet, derives their privacy keys, and obtains an access token from the server. After authentication, the user has a privacy address — a public identifier (separate from their Ethereum address) that others use to send them private transfers. See Key Management for details on key derivation.
Choosing an Auth Method
Before integrating authentication, choose how your app verifies users. See the auth method comparison table in App Setup. For development, the SDK authenticates directly — no backend needed. For production, you’ll route authentication through your backend using a token provider.User Experience
From the user’s perspective, authentication looks like this:- Your app calls
authenticate() - User sees wallet popups (depending on key source and account mode — see below)
- User is logged in — SDK handles everything else behind the scenes
Wallet Popups
The number of wallet signature requests depends on how keys are derived:The first popup (when using
walletDerived) asks the user to sign a message to derive their privacy keys. The second popup registers an authorization key on-chain. Both are one-time per session.Returning Users
When a user returns to your app and their session is still saved (via persistence or manual session import), they can re-authenticate with zero wallet popups. The SDK uses the stored keys and only refreshes the server token. Approval-only accounts are an exception: a new device, or a device without resident keys, signs once for login and once to authorize the one-time escrow export. The export signature is bound to a short-lived, single-use nonce; an unexpired bearer token alone cannot release permanent keys.Basic Usage
Approval-only EOA multichain authentication
SetapprovalOnly: true on a root SDK instance. The SDK discovers chainId and the chain’s AuthRegistry from that server’s /api/v1/info; applications must not supply an AuthRegistry address.
An EOA has exactly one global approval-only identity. Every chain must contain the account derived from that identity’s same owner and salt. Deployments fail closed with a conflict if an EOA has multiple approval-only accounts or if a chain contains a different account ID; such accounts require an operator-assisted migration and cannot be selected through this API.
When the identity exists globally but not on the current chain, authentication returns a normal EOA transaction request:
accountCreationRequired, so retrying after a slow wallet transaction or indexer delay always performs a fresh login.
Multiple chains
Approval-only mode currently uses one root SDK per chain;forChain() rejects this mode because approval plans and submission state are owned by the root KeyVault. For each chain:
- Create a root SDK with that chain’s
serverUrlandapprovalOnly: true. - Switch the wallet to the server-advertised chain before submitting a prepared transaction.
- Authenticate and retain that root only while using the chain.
- Call
logout()anddispose()before discarding it. Do not share a root instance or its session between chains.
Approval-only trust model
Approval-only multichain recovery is an explicit exception to split-key vault confidentiality. The TEE stores a server-decryptable viewing key and can read the nullifying key associated with the identity. Always Encrypted protects these values from a SQL operator, but a compromised TEE process can recover them and becomes the account’s privacy root. These keys reveal transaction history and ownership relationships but do not authorize spends: approval-only accounts still require an on-chain approval for every spend.PIN / Password Unlock
If you’ve configured persistence withpin or password unlock, authenticate() may return credentialRequired instead of logging in immediately. This happens when:
- First time — The SDK needs a PIN/password to encrypt the key vault
- Returning user — The SDK needs the PIN/password to decrypt the stored keys
If persistence uses
biometric or passkey unlock, the platform prompt appears automatically — no extra code needed.Token Providers
A token provider is a function you pass toauthenticate() that routes the login request through your backend. Your backend adds credentials (API secret, Privy token, or custom JWT) before forwarding to Privacy Boost. This keeps secrets out of client-side code.
When do you need one? Only if your app uses API secret, Privy, or custom JWT authentication. For direct auth (development), no token provider is needed. See App Setup for details.
How it works
Implementation
{ token: string, expiresIn: number }.
Logging Out
Use
clearSession() when you want to expire the token but let the user quickly re-login (e.g., switching accounts on the server side). Use logout() for a full sign-out.
Next Steps
If you’re using a production auth method, set up your integration next:API Secret
Server-to-server authentication with client credentials
Custom JWT
Auth0, Firebase, Supabase, Clerk, or any OIDC provider
Privy
Social login and embedded wallets via Privy
Dynamic
Wallet connection and embedded wallets via Dynamic
- Key Management — Choose a key source and configure persistence
- Error Handling — Handle auth and operation errors
- Keys & Encryption — Deep dive into how auth keys, viewing keys, and privacy addresses work