/** * Host-controlled KEK boundary. * * A BFF normally implements this with Cloud KMS. A native confidential app * implements the same boundary with a non-exportable Keychain/Keystore key. * The adapter never receives the user's PIN. */ export type ServerProfileSealer = Readonly<{ seal(cleartext: string, aad: string): Promise; unseal(ciphertext: string, aad: string): Promise; }>; /** Persisted scrypt work factor. The salt and parameters are public metadata. */ export type ProfileScryptParameters = Readonly<{ name: 'scrypt'; saltBase64Url: string; cost: number; blockSize: number; parallelization: number; keyLength: 32; }>; /** * Portable v1 envelope for a profile secret. * * `ciphertext` contains the secret encrypted by a random DEK. The host first * wraps that DEK; the PIN-derived key then encrypts the host-wrapped value. * Opening therefore requires both factors without exposing either factor to * the other adapter. */ export type PinProtectedProfileSecret = Readonly<{ version: 'gdc-pin-host-envelope-v1'; kdf: ProfileScryptParameters; payload: AesGcmCiphertext; pinWrappedHostDek: AesGcmCiphertext; }>; export type AesGcmCiphertext = Readonly<{ ivBase64Url: string; ciphertextBase64Url: string; tagBase64Url: string; }>; export type ProfileProtectionOptions = Readonly<{ cost?: number; blockSize?: number; parallelization?: number; }>; /** Distinguishes a wrong PIN from a host KMS outage or corrupted payload. */ export declare class ProfilePinRejectedError extends Error { constructor(); } /** * Encrypt one seed, private-key export or credential using a fresh DEK. * * The returned salt is intentionally stored in clear. Security comes from the * PIN work factor, the independent host KEK and authenticated encryption, not * from hiding the salt or algorithm parameters. */ export declare function protectServerProfileSecret(cleartext: string, pin: string, aad: string, hostSealer: ServerProfileSealer, options?: ProfileProtectionOptions): Promise; /** * Open one protected profile secret using both PIN and host protection. * * The PIN layer is authenticated before the host adapter is called. A wrong * PIN therefore neither reaches KMS nor becomes indistinguishable from a KMS * availability failure in audit logs. */ export declare function openServerProfileSecret(envelope: PinProtectedProfileSecret, pin: string, aad: string, hostSealer: ServerProfileSealer): Promise;