Skip to content

Conversation

@calvinbrewer
Copy link
Contributor

No description provided.


- **`cs_ciphertext_v1(val JSONB)`**: Extracts the ciphertext for decryption by CipherStash Proxy.
- **`cs_match_v1(val JSONB)`**: Retrieves the match index for equality comparisons.
- **`cs_unique_v1(val JSONB)`**: Retrieves the unique index for enforcing uniqueness.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a bit confusing, but our unique indexes are deterministic ciphertexts that can be used for equality checks. We do use them for enforcing uniqueness when paired with a DB-level unique constraint, but they can also generally be used for equality checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if it's worth explicitly listing each PG operator that each index type supports along with some example queries of how to use them (WHERE cs_match_v1(users.email) @> cs_match_v1($1)) for match indexes for example).


-- Remove an ore index from users.name
cs_remove_index('users', 'name', 'ore');
```
Copy link
Contributor

@CDThomas CDThomas Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To mark the Encrypt config changes as "active", users also need to run:

SELECT cs_encrypt_v1();
SELECT cs_activate_v1();

Example in a migration file: https://github.com/cipherstash/cipherstash-suite/pull/987/files#diff-1e92c01435adeee6d8ae18de8ea1fb56e00c7c3e67fd2f0d0150f87203dcb64aR24-R25.

These functions will be part of zero-downtime migration support. Maybe we should also have a shorthand for creating an index and immediately setting it to active? Not sure yet.

There are some more details on how we're thinking of handling zero-downtime migrations here: https://www.notion.so/cipherstash/Zero-Downtime-Encryptindexing-33c5ffe5b16c4e0386514a716de4d050?pvs=4

@calvinbrewer calvinbrewer marked this pull request as ready for review October 3, 2024 19:56
@calvinbrewer calvinbrewer merged commit db6aa24 into main Oct 3, 2024
@calvinbrewer calvinbrewer deleted the updated-readme branch October 3, 2024 19:57
tobyhede pushed a commit that referenced this pull request Oct 27, 2025
feat: organize and update readme
tobyhede added a commit that referenced this pull request Oct 30, 2025
Extends foreign_key_constraint_with_encrypted test to verify FK
enforcement behavior with deterministic test data. Demonstrates that:

1. FK constraints DO work with deterministic encrypted data (test framework)
2. Successfully insert child with matching parent reference
3. Correctly reject child with non-existent parent reference

Documents PRODUCTION LIMITATION: In real-world usage with non-deterministic
encryption, FK constraints don't provide meaningful referential integrity
because each encryption of the same plaintext produces different ciphertext.

Adds 4 new assertions testing FK enforcement behavior.

Addresses FINAL_CODE_REVIEW.md recommendation #4 (P2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants