Article 16 – Deterministic Encryption in Google Cloud

Alright, let us talk about something that trips up a lot of people when they encounter it for the first time — Deterministic Encryption. If you have worked with databases and security, you know that encryption is supposed to make data unreadable to anyone who does not have the key. That part is straightforward. But what happens when you need to search through encrypted data? That is where things get interesting.

The Problem — You Cannot Search Encrypted Data

Let me set the stage. You have a database column containing, say, Social Security numbers or customer email addresses. You have encrypted this column because you are a responsible engineer. Good.

Now, someone asks you to find all records where the email is [email protected]. With traditional encryption — what we call probabilistic encryption — you have a problem. This type of encryption introduces randomness into the process. So if you encrypt [email protected] twice, you get two completely different ciphertexts each time.

That means you cannot just encrypt the search term and look for a match. The encrypted value in the database will be different from the one you just generated, even though the plaintext is the same. To search, you would have to decrypt every single row first, then compare. That defeats the purpose of encryption and is a performance disaster.

Enter Deterministic Encryption

Deterministic encryption solves this specific problem. The rule is simple: for a given plaintext and a given key, the encryption algorithm always produces the exact same ciphertext.

  • Encrypt "Hello" with Key A → you get Ciphertext X
  • Encrypt "Hello" again with Key A → you still get Ciphertext X
  • Every time, same input, same output

This is fundamentally different from probabilistic encryption, which uses a random element like an Initialization Vector (IV) to make sure the same plaintext produces a different ciphertext every time.

Why This Matters — Practical Use Cases

The whole reason deterministic encryption exists is to allow basic database operations on encrypted data without decrypting it first:

Searching and Filtering (Equality Checks)
This is the big one. Since identical plaintexts produce identical ciphertexts, you can perform equality comparisons. If a client wants to find records with the last name “Smith,” they encrypt “Smith” once and search the encrypted column for an exact match. This allows indexing and fast lookups — which is simply impossible with probabilistic encryption.

Data Deduplication
Sometimes called “convergent encryption” in this context. You can identify duplicate files or data blocks even when they are encrypted, because identical data produces identical ciphertext. This is useful for efficient storage management.

The Security Trade-Off — And It Is a Real One

Now, I have to be honest here. Deterministic encryption is a compromise. You are trading security strength for practicality. Here is what you are giving up:

Ciphertext Recognition
An adversary can identify identical plaintexts by observing identical ciphertexts. If an attacker knows that a specific ciphertext corresponds to “CEO Salary,” then every time they see that same ciphertext, they know the plaintext. That is a real vulnerability.

Frequency Analysis
If the plaintext field has low entropy — meaning a small number of possible values, like a gender field with only “Male” or “Female” — an attacker can perform statistical analysis. The most frequent ciphertext probably corresponds to the most frequent plaintext. This kind of attack can be devastating on low-cardinality data.

No Semantic Security
Deterministic encryption cannot achieve “semantic security” — the guarantee that ciphertext reveals absolutely nothing about the plaintext. This is the strongest form of encryption security, and deterministic schemes simply cannot provide it by definition.

The Comparison Table
FeatureDeterministic EncryptionProbabilistic Encryption
Output for same plaintext/keyAlways the same ciphertextAlways a different ciphertext
RandomnessNone (or a fixed IV)Uses a random element (IV/Nonce)
Search/Filter on ciphertextYes (equality checks)No (must decrypt first)
Semantic SecurityCannot achieveCan achieve (stronger)
Information LeakageLeaks equality and frequency patternsNo leakage
Common Use CaseSearching encrypted database columnsSecure communication, data at rest
When Should You Actually Use It?

Deterministic encryption is a specialized tool, not a general-purpose solution. Use it when:

  • You have a genuine need to search or filter on encrypted fields
  • The data in those fields has high entropy (many possible values, not just 2 or 3)
  • You understand and accept the security trade-off

Do NOT use it when:
– The field contains low-entropy data (like gender, boolean values, or status codes)
– You do not need to search on the encrypted data — just use probabilistic encryption instead
– The data is extremely sensitive and the frequency pattern could reveal critical information

The Bottom Line

The decision to use deterministic encryption should be made with your eyes wide open. It requires careful design. You need to make sure the fields you are encrypting do not contain low-entropy, easily guessable, or highly repetitive data that could be exploited by an attacker observing the repeating ciphertexts.

Basically, it is the right tool for the right job. Use it where searchability on encrypted fields is non-negotiable and the data has enough variety to mitigate simple frequency attacks. Use probabilistic encryption everywhere else.