liveBook · Manning

Deterministic encryption

As explained in MongoDB 8.0 in Action, Third Edition

Deterministic encryption is an encryption technique in which the same plaintext encrypted with the same key always produces the same ciphertext.

Deterministic encryption produces the same ciphertext whenever the same plaintext is encrypted with the same key. In MongoDB client-side field-level encryption, this predictable output enables exact equality queries while keeping sensitive values hidden from MongoDB. section 20.5.4

Use deterministic encryption with these constraints:

  • Apply it when an application must match encrypted values exactly, such as a social security number. section 20.5.4
  • Do not expect range, prefix, suffix, or substring queries; those require comparisons beyond exact equality. section 20.5.4
  • Consider Queryable Encryption when encrypted equality, range, prefix, suffix, or substring searches are required. section 20.5.4

Encrypted social security number

An application sends a document containing a socialSecurityNumber to an authenticated client. The client-side driver encrypts the field before transmission, stores ciphertext in MongoDB, and decrypts authorized results; MongoDB never sees the plaintext. section 20.5.4

{
  "name": "Name Surname",
  "socialSecurityNumber": "123-45-6789",
  "email": "user@example.com"
}

Inspect the plaintext document before client-side field-level encryption. section 20.5.4

{
  "name": " Name Surname",
  "socialSecurityNumber": { "$binary": "AE4F0F9DE7..." },
  "email": "user@example.com"
}

Compare the stored document after the sensitive field has become ciphertext. section 20.5.4

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines repeatable ciphertext and its equality-query consequence, but stops short of cryptographic implementation details.
Examples
Uses social security numbers, plaintext and ciphertext documents, and an authenticated client query workflow.
What it assumes
Assumes basic MongoDB querying and encryption concepts while explaining plaintext, ciphertext, keys, and client-side processing.
What you can do after
Evaluate whether deterministic encryption fits an exact-match requirement and recognize when broader encrypted search is necessary.
How it connects
Connects client-side field-level encryption with CSFLE, encryption keys, and Queryable Encryption.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.