Skip to content

Commit 91e3582

Browse files
committed
docs: update eql functions to v2
1 parent 5dfa97d commit 91e3582

File tree

3 files changed

+145
-107
lines changed

3 files changed

+145
-107
lines changed

README.md

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
Encrypt Query Language (EQL) is a set of abstractions for transmitting, storing, and interacting with encrypted data and indexes in PostgreSQL.
77

8-
> [!TIP]
9-
> **New to EQL?** Start with the higher level helpers for EQL in [Python](https://github.com/cipherstash/eqlpy), [Go](https://github.com/cipherstash/goeql), or [JavaScript](https://github.com/cipherstash/jseql) and [TypeScript](https://github.com/cipherstash/jseql), or the [examples](#helper-packages-and-examples) for those languages.
8+
> [!TIP] > **New to EQL?** Start with the higher level helpers for EQL in [Python](https://github.com/cipherstash/eqlpy), [Go](https://github.com/cipherstash/goeql), or [JavaScript](https://github.com/cipherstash/jseql) and [TypeScript](https://github.com/cipherstash/jseql), or the [examples](#helper-packages-and-examples) for those languages.
109
1110
Store encrypted data alongside your existing data:
1211

@@ -29,16 +28,15 @@ Store encrypted data alongside your existing data:
2928
- [Inserting Data](#inserting-data)
3029
- [Reading Data](#reading-data)
3130
- [Configuring indexes for searching data](#configuring-indexes-for-searching-data)
32-
- [Adding an index (`cs_add_index_v1`)](#adding-an-index-cs_add_index_v1)
31+
- [Adding an index](#adding-an-index)
3332
- [Searching data with EQL](#searching-data-with-eql)
34-
- [Equality search (`cs_unique_v1`)](#equality-search-cs_unique_v1)
35-
- [Full-text search (`cs_match_v1`)](#full-text-search-cs_match_v1)
36-
- [Range queries (`cs_ore_64_8_v1`)](#range-queries-cs_ore_64_8_v1)
33+
- [Equality search](#equality-search)
34+
- [Full-text search](#full-text-search)
35+
- [Range queries](#range-queries)
36+
- [Array Operations](#array-operations)
37+
- [JSON Path Operations](#json-path-operations)
3738
- [JSON and JSONB support](#json-and-jsonb-support)
3839
- [Frequently Asked Questions](#frequently-asked-questions)
39-
- [How do I integrate CipherStash EQL with my application?](#how-do-i-integrate-cipherstash-eql-with-my-application)
40-
- [Can I use EQL without the CipherStash Proxy?](#can-i-use-eql-without-the-cipherstash-proxy)
41-
- [How is data encrypted in the database?](#how-is-data-encrypted-in-the-database)
4240
- [Helper packages](#helper-packages-and-examples)
4341
- [Releasing](#releasing)
4442
- [Developing](#developing)
@@ -79,34 +77,34 @@ Once the custom types and functions are installed in your PostgreSQL database, y
7977

8078
### Enable encrypted columns
8179

82-
Define encrypted columns using the `cs_encrypted_v1` domain type, which extends the `jsonb` type with additional constraints to ensure data integrity.
80+
Define encrypted columns using the `eql_v1_encrypted` type, which extends the `jsonb` type with additional constraints to ensure data integrity.
8381

8482
**Example:**
8583

8684
```sql
8785
CREATE TABLE users (
8886
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
89-
encrypted_email cs_encrypted_v1
87+
encrypted_email eql_v1_encrypted
9088
);
9189
```
9290

9391
### Configuring the column
9492

95-
Initialize the column using the `cs_add_column_v1` function to enable encryption and decryption via CipherStash Proxy.
93+
Initialize the column using the `eql_v1.add_column` function to enable encryption and decryption via CipherStash Proxy.
9694

9795
```sql
98-
SELECT cs_add_column_v1('users', 'encrypted_email');
96+
SELECT eql_v1.add_column('users', 'encrypted_email');
9997
```
10098

101-
**Note:** This function allows you to encrypt and decrypt data but does not enable searchable encryption. See [Querying Data with EQL](#querying-data-with-eql) for enabling searchable encryption.
99+
**Note:** This function allows you to encrypt and decrypt data but does not enable searchable encryption. See [Searching data with EQL](#searching-data-with-eql) for enabling searchable encryption.
102100

103101
### Activating configuration
104102

105103
After modifying configurations, activate them by running:
106104

107105
```sql
108-
SELECT cs_encrypt_v1();
109-
SELECT cs_activate_v1();
106+
SELECT eql_v1.encrypt();
107+
SELECT eql_v1.activate();
110108
```
111109

112110
**Important:** These functions must be run after any modifications to the configuration.
@@ -116,7 +114,7 @@ SELECT cs_activate_v1();
116114
CipherStash Proxy refreshes the configuration every 60 seconds. To force an immediate refresh, run:
117115

118116
```sql
119-
SELECT cs_refresh_encrypt_config();
117+
SELECT eql_v1.reload_config();
120118
```
121119

122120
> Note: This statement must be executed when connected to CipherStash Proxy.
@@ -191,13 +189,12 @@ In order to perform searchable operations on encrypted data, you must configure
191189
> **IMPORTANT:** If you have existing data that's encrypted and you add or modify an index, all the data will need to be re-encrypted.
192190
> This is due to the way CipherStash Proxy handles searchable encryption operations.
193191
194-
### Adding an index (`cs_add_index_v1`)
192+
### Adding an index
195193

196-
Add an index to an encrypted column.
197-
This function also behaves the same as `cs_add_column_v1` but with the additional index configuration.
194+
Add an index to an encrypted column using the `eql_v1.add_index` function:
198195

199196
```sql
200-
SELECT cs_add_index_v1(
197+
SELECT eql_v1.add_index(
201198
'table_name', -- Name of the table
202199
'column_name', -- Name of the column
203200
'index_name', -- Index kind ('unique', 'match', 'ore', 'ste_vec')
@@ -211,19 +208,19 @@ You can read more about the index configuration options [here](docs/reference/IN
211208
**Example (Unique index):**
212209

213210
```sql
214-
SELECT cs_add_index_v1(
211+
SELECT eql_v1.add_index(
215212
'users',
216213
'encrypted_email',
217214
'unique',
218215
'text'
219216
);
220217
```
221218

222-
After adding an index, you have to activate the configuration.
219+
After adding an index, you have to activate the configuration:
223220

224221
```sql
225-
SELECT cs_encrypt_v1();
226-
SELECT cs_activate_v1();
222+
SELECT eql_v1.encrypt();
223+
SELECT eql_v1.activate();
227224
```
228225

229226
## Searching data with EQL
@@ -232,14 +229,14 @@ EQL provides specialized functions to interact with encrypted data, supporting o
232229

233230
In order to use the specialized functions, you must first configure the corresponding indexes.
234231

235-
### Equality search (`cs_unique_v1`)
232+
### Equality search
236233

237-
Enable equality search on encrypted data.
234+
Enable equality search on encrypted data using the `eql_v1.unique` function.
238235

239236
**Index configuration example:**
240237

241238
```sql
242-
SELECT cs_add_index_v1(
239+
SELECT eql_v1.add_index(
243240
'users',
244241
'encrypted_email',
245242
'unique',
@@ -251,7 +248,7 @@ SELECT cs_add_index_v1(
251248

252249
```sql
253250
SELECT * FROM users
254-
WHERE cs_unique_v1(encrypted_email) = cs_unique_v1(
251+
WHERE eql_v1.unique(encrypted_email) = eql_v1.unique(
255252
'{"v":1,"k":"pt","p":"[email protected]","i":{"t":"users","c":"encrypted_email"},"q":"unique"}'
256253
);
257254
```
@@ -262,14 +259,14 @@ Equivalent plaintext query:
262259
SELECT * FROM users WHERE email = '[email protected]';
263260
```
264261

265-
### Full-text search (`cs_match_v1`)
262+
### Full-text search
266263

267-
Enables basic full-text search on encrypted data.
264+
Enables basic full-text search on encrypted data using the `eql_v1.match` function.
268265

269266
**Index configuration example:**
270267

271268
```sql
272-
SELECT cs_add_index_v1(
269+
SELECT eql_v1.add_index(
273270
'users',
274271
'encrypted_email',
275272
'match',
@@ -282,7 +279,7 @@ SELECT cs_add_index_v1(
282279

283280
```sql
284281
SELECT * FROM users
285-
WHERE cs_match_v1(encrypted_email) @> cs_match_v1(
282+
WHERE eql_v1.match(encrypted_email) @> eql_v1.match(
286283
'{"v":1,"k":"pt","p":"test","i":{"t":"users","c":"encrypted_email"},"q":"match"}'
287284
);
288285
```
@@ -293,9 +290,9 @@ Equivalent plaintext query:
293290
SELECT * FROM users WHERE email LIKE '%test%';
294291
```
295292

296-
### Range queries (`cs_ore_64_8_v1`)
293+
### Range queries
297294

298-
Enable range queries on encrypted data. Supports:
295+
Enable range queries on encrypted data using the `eql_v1.ore_64_8_v1`, `eql_v1.ore_cllw_u64_8`, or `eql_v1.ore_cllw_var_8` functions. Supports:
299296

300297
- `ORDER BY`
301298
- `WHERE`
@@ -304,7 +301,7 @@ Enable range queries on encrypted data. Supports:
304301

305302
```sql
306303
SELECT * FROM users
307-
WHERE cs_ore_64_8_v1(encrypted_date) < cs_ore_64_8_v1(
304+
WHERE eql_v1.ore_64_8_v1(encrypted_date) < eql_v1.ore_64_8_v1(
308305
'{"v":1,"k":"pt","p":"2023-10-05","i":{"t":"users","c":"encrypted_date"},"q":"ore"}'
309306
);
310307
```
@@ -319,7 +316,7 @@ SELECT * FROM users WHERE date < '2023-10-05';
319316

320317
```sql
321318
SELECT id FROM users
322-
ORDER BY cs_ore_64_8_v1(encrypted_field) DESC;
319+
ORDER BY eql_v1.ore_64_8_v1(encrypted_field) DESC;
323320
```
324321

325322
Equivalent plaintext query:
@@ -328,18 +325,31 @@ Equivalent plaintext query:
328325
SELECT id FROM users ORDER BY field DESC;
329326
```
330327

331-
**Example (Grouping):**
328+
### Array Operations
329+
330+
EQL supports array operations on encrypted data:
332331

333332
```sql
334-
SELECT grouped_value_v1(encrypted_field) COUNT(*)
335-
FROM users
336-
GROUP BY cs_ore_64_8_v1(encrypted_field)
333+
-- Get array length
334+
SELECT eql_v1.jsonb_array_length(encrypted_array) FROM users;
335+
336+
-- Get array elements
337+
SELECT eql_v1.jsonb_array_elements(encrypted_array) FROM users;
338+
339+
-- Get array element ciphertexts
340+
SELECT eql_v1.jsonb_array_elements_text(encrypted_array) FROM users;
337341
```
338342

339-
Equivalent plaintext query:
343+
### JSON Path Operations
344+
345+
EQL supports JSON path operations on encrypted data using the `->` and `->>` operators:
340346

341347
```sql
342-
SELECT field, COUNT(*) FROM users GROUP BY field;
348+
-- Get encrypted value at path
349+
SELECT encrypted_data->'$.field' FROM users;
350+
351+
-- Get ciphertext at path
352+
SELECT encrypted_data->>'$.field' FROM users;
343353
```
344354

345355
## JSON and JSONB support
@@ -363,15 +373,15 @@ No, CipherStash Proxy is required to handle the encryption and decryption operat
363373

364374
### How is data encrypted in the database?
365375

366-
Data is encrypted using CipherStash's cryptographic schemes and stored in the `cs_encrypted_v1` column as a JSONB payload.
376+
Data is encrypted using CipherStash's cryptographic schemes and stored in the `eql_v1_encrypted` column as a JSONB payload.
367377
Encryption and decryption are handled by CipherStash Proxy.
368378

369379
## Helper packages and examples
370380

371381
We've created a few langauge specific packages to help you interact with the payloads:
372382

373-
| Language | ORM | Example | Package |
374-
| ---------- | ----------- | ----------------------------------------------------------------- | ---------------------------------------------------------------- |
383+
| Language | ORM | Example | Package |
384+
| ---------- | ----------- | ---------------------------------------------------------------- | --------------------------------------------- |
375385
| Go | Xorm | [Go/Xorm examples](./examples/go/xorm/README.md) | [goeql](https://github.com/cipherstash/goeql) |
376386
| TypeScript | Drizzle | [Drizzle examples](./examples/javascript/apps/drizzle/README.md) | [jseql](https://github.com/cipherstash/jseql) |
377387
| TypeScript | Prisma | [Drizzle examples](./examples/javascript/apps/prisma/README.md) | [jseql](https://github.com/cipherstash/jseql) |

0 commit comments

Comments
 (0)