Crypto Prisma
    Preparing search index...

    Interface EncryptionConfig

    Configuration for the encryption middleware.

    const config: EncryptionConfig = {
    key: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    encryptedFields: [{ model: "User", fields: ["email", "phone"] }],
    algorithm: "xchacha20-poly1305",
    deterministicFields: ["email"],
    };
    interface EncryptionConfig {
        key: string;
        encryptedFields: FieldConfig[];
        algorithm?: "xchacha20-poly1305" | "aes-256-gcm";
        deterministicFields?: string[];
        allowPlaintextFallback?: boolean;
        acceptLegacyCiphertext?: boolean;
        blindIndexKeyDerivation?: "legacy" | "hkdf";
    }
    Index
    key: string

    Hex-encoded 256-bit encryption key.

    encryptedFields: FieldConfig[]

    Models and fields to encrypt.

    algorithm?: "xchacha20-poly1305" | "aes-256-gcm"

    Encryption algorithm. Only "xchacha20-poly1305" is implemented; the option is accepted for forward compatibility and currently has no effect.

    deterministicFields?: string[]

    Fields stored as an HMAC-SHA-256 blind index instead of ciphertext, so they can be matched exactly in where clauses. Reads return the stored MAC, not the plaintext: the blind index is one-way.

    allowPlaintextFallback?: boolean

    Return a stored value as-is when it is not a ciphertext at all, instead of throwing a FieldDecryptionError. Meant only for the window in which existing plaintext rows are being migrated. A value in the v2: format that fails authentication is always rejected.

    false
    
    acceptLegacyCiphertext?: boolean

    Accept legacy ciphertexts written before the v2: format (sealed with the configured key and no associated data). Legacy values are not bound to their model and field, so anyone able to write the database could move one into another encrypted field. Set this only while re-writing old rows, then remove it.

    false
    
    blindIndexKeyDerivation?: "legacy" | "hkdf"

    Key used for the blind index of deterministicFields.

    • "legacy": HMAC with the configured key, as in earlier versions, so existing index values keep matching.
    • "hkdf": HMAC with a subkey derived by HKDF-SHA-256 (info crypto-prisma/bidx/v1). Every stored index value must be recomputed when switching an existing database to this mode.
    "legacy"