Skip to content

Commit de0cdbd

Browse files
committed
feat: rename v1 to v2
1 parent 91e3582 commit de0cdbd

File tree

101 files changed

+2847
-2872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2847
-2872
lines changed

DEVELOPMENT.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ All files must have at least one declaration, and the default is to reference th
7777

7878
## Set up a local development environment
7979

80-
> [!IMPORTANT]
81-
> **Before you follow this how-to** you need to have this software installed:
82-
> - [mise](https://mise.jdx.dev/) — see the [installing mise](#installing-mise) instructions
83-
> - [Docker](https://www.docker.com/) — see Docker's [documentation for installing](https://docs.docker.com/get-started/get-docker/)
80+
> [!IMPORTANT] > **Before you follow this how-to** you need to have this software installed:
81+
>
82+
> - [mise](https://mise.jdx.dev/) — see the [installing mise](#installing-mise) instructions
83+
> - [Docker](https://www.docker.com/) — see Docker's [documentation for installing](https://docs.docker.com/get-started/get-docker/)
8484
8585
Local development quickstart:
8686

87-
``` shell
87+
```shell
8888
# Clone the repo
8989
git clone https://github.com/cipherstash/encrypt-query-language
9090
cd encrypt-query-language
@@ -222,12 +222,11 @@ You can also [run the tests locally](#running-tests-locally) when doing local de
222222

223223
### Running tests locally
224224

225-
> [!IMPORTANT]
226-
> **Before you run the tests locally** you need to [set up a local dev environment](#set-up-a-local-development-environment).
225+
> [!IMPORTANT] > **Before you run the tests locally** you need to [set up a local dev environment](#set-up-a-local-development-environment).
227226
228227
To run tests locally with PostgreSQL 17:
229228

230-
``` shell
229+
```shell
231230
# Start a postgres instance (defaults to PostgreSQL 17)
232231
mise run postgres:up --extra-args "--detach --wait"
233232

@@ -292,67 +291,66 @@ mise run build
292291

293292
This produces two SQL files in `releases/`:
294293

295-
- An installer (`cipherstash-encrypt.sql`), and
296-
- An uninstaller (`cipherstash-encrypt-uninstall.sql`)
294+
- An installer (`cipherstash-encrypt.sql`), and
295+
- An uninstaller (`cipherstash-encrypt-uninstall.sql`)
297296

298297
## Structure
299298

300299
### Schema
301300

302-
EQL is installed into the `eql_v1` PostgreSQL schema.
301+
EQL is installed into the `eql_v2` PostgreSQL schema.
303302

304303
### Types
305304

306305
#### Encrypted column type
307306

308-
`public.eql_v1_encrypted` is EQL's encrypted column type, defined as PostgreSQL composite type.
307+
`public.eql_v2_encrypted` is EQL's encrypted column type, defined as PostgreSQL composite type.
309308

310309
This column type is used for storing the encrypted value and any associated indexes for searching.
311310
The associated indexes are described in the [index term types](#index-term-types) section.
312311

313-
`public.eql_v1_encrypted` is in the public schema, because once it's used by a user in one of their tables, encrypted column types cannot be dropped without dropping data.
312+
`public.eql_v2_encrypted` is in the public schema, because once it's used by a user in one of their tables, encrypted column types cannot be dropped without dropping data.
314313

315314
#### Encrypted index term types
316315

317316
Each type of encrypted index (`unique`, `match`, `ore`) has an associated type, functions, and operators.
318317

319318
These are transient runtime types, used internally by EQL functions and operators:
320319

321-
- `eql_v1.blake3`
322-
- `eql_v1.unique_index`
323-
- `eql_v1.match`
324-
- `eql_v1.ore_cllw_u64_8`
325-
- `eql_v1.ore_cllw_var_8`
326-
- `eql_v1.ore_64_8_v1`
327-
- `eql_v1.ore_64_8_v1_term`
320+
- `eql_v2.blake3`
321+
- `eql_v2.unique_index`
322+
- `eql_v2.match`
323+
- `eql_v2.ore_cllw_u64_8`
324+
- `eql_v2.ore_cllw_var_8`
325+
- `eql_v2.ore_64_8_v2`
326+
- `eql_v2.ore_64_8_v2_term`
328327

329328
The data in the column is converted into these types, when any operations are being performed on that encrypted data.
330329

331330
### Operators
332331

333332
Searchable encryption functionality is driven by operators on two types:
334333

335-
- EQL's `eql_v1_encrypted` column type
334+
- EQL's `eql_v2_encrypted` column type
336335
- PostgreSQL's `jsonb` column type
337336

338-
For convenience, operators allow comparisons between `eql_v1_encrypted` and `jsonb` column types.
337+
For convenience, operators allow comparisons between `eql_v2_encrypted` and `jsonb` column types.
339338

340339
Operators allow comparisons between:
341340

342-
- `eql_v1_encrypted` and `eql_v1_encrypted`
343-
- `jsonb` and `eql_v1_encrypted`
344-
- `eql_v1_encrypted` and `jsonb`
341+
- `eql_v2_encrypted` and `eql_v2_encrypted`
342+
- `jsonb` and `eql_v2_encrypted`
343+
- `eql_v2_encrypted` and `jsonb`
345344

346-
Operators defined on the `eql_v1_encrypted` dispatch to the underlying index terms based on the most efficient order of operations.
345+
Operators defined on the `eql_v2_encrypted` dispatch to the underlying index terms based on the most efficient order of operations.
347346

348347
For example, it is possible to have both `unique` and `ore` indexes defined.
349348
For equality (`=`, `<>`) operations, a `unique` index term is a text comparison and should be preferred over an `ore` index term.
350349

351-
The index term types and functions are internal implementation details and should not be exposed as operators on the `eql_v1_encrypted` type.
352-
For example, `eql_v1_encrypted` should not have an operator with the `ore_64_8_v1` type.
350+
The index term types and functions are internal implementation details and should not be exposed as operators on the `eql_v2_encrypted` type.
351+
For example, `eql_v2_encrypted` should not have an operator with the `ore_64_8_v2` type.
353352
Users should never need to think about or interact with EQL internals.
354353

355-
356354
#### Working without operators
357355

358356
There are scenarios where users are unable to install EQL operators in your database.
@@ -363,12 +361,12 @@ EQL can still be used, but requires the use of functions instead of operators.
363361
For example, to perform an equality query:
364362

365363
```sql
366-
SELECT email FROM users WHERE eql_v1.eq(email, $1);
364+
SELECT email FROM users WHERE eql_v2.eq(email, $1);
367365
```
368366

369367
### Configuration table
370368

371-
EQL uses a table for tracking configuration state in the database, called `public.eql_v1_configuration`.
369+
EQL uses a table for tracking configuration state in the database, called `public.eql_v2_configuration`.
372370

373371
This table should never be dropped, except by a user explicitly uninstalling EQL.
374372

@@ -381,14 +379,14 @@ Experimenting with using a Composite type instead of a Domain type for the encry
381379
Composite types are a bit more capable. Domain types are more like an alias for the underlying type (in this case jsonb)
382380
The consequence of using a Composite type is that the data is stored in the column as a Tuple - effectively the data is wrapped in ()
383381
This means
384-
on insert/update the data needs to be cast to eql_v1_encrypted (proxy mapping will handle)
382+
on insert/update the data needs to be cast to eql_v2_encrypted (proxy mapping will handle)
385383
on read the data needs to be cast back to jsonb if a customer needs the raw json (for data lake transfer etc etc)
386384
Already built cast helpers so syntax is something like
387385
INSERT INTO encrypted (e) VALUES (
388-
eql_v1.to_encrypted('{}')
386+
eql_v2.to_encrypted('{}')
389387
);
390388
391389
INSERT INTO encrypted (e) VALUES (
392-
'{}'::jsonb::eql_v1_encrypted
390+
'{}'::jsonb::eql_v2_encrypted
393391
);
394392
-->

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ Once the custom types and functions are installed in your PostgreSQL database, y
7777

7878
### Enable encrypted columns
7979

80-
Define encrypted columns using the `eql_v1_encrypted` type, which extends the `jsonb` type with additional constraints to ensure data integrity.
80+
Define encrypted columns using the `eql_v2_encrypted` type, which extends the `jsonb` type with additional constraints to ensure data integrity.
8181

8282
**Example:**
8383

8484
```sql
8585
CREATE TABLE users (
8686
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
87-
encrypted_email eql_v1_encrypted
87+
encrypted_email eql_v2_encrypted
8888
);
8989
```
9090

9191
### Configuring the column
9292

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

9595
```sql
96-
SELECT eql_v1.add_column('users', 'encrypted_email');
96+
SELECT eql_v2.add_column('users', 'encrypted_email');
9797
```
9898

9999
**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.
@@ -103,8 +103,8 @@ SELECT eql_v1.add_column('users', 'encrypted_email');
103103
After modifying configurations, activate them by running:
104104

105105
```sql
106-
SELECT eql_v1.encrypt();
107-
SELECT eql_v1.activate();
106+
SELECT eql_v2.encrypt();
107+
SELECT eql_v2.activate();
108108
```
109109

110110
**Important:** These functions must be run after any modifications to the configuration.
@@ -114,7 +114,7 @@ SELECT eql_v1.activate();
114114
CipherStash Proxy refreshes the configuration every 60 seconds. To force an immediate refresh, run:
115115

116116
```sql
117-
SELECT eql_v1.reload_config();
117+
SELECT eql_v2.reload_config();
118118
```
119119

120120
> Note: This statement must be executed when connected to CipherStash Proxy.
@@ -191,10 +191,10 @@ In order to perform searchable operations on encrypted data, you must configure
191191
192192
### Adding an index
193193

194-
Add an index to an encrypted column using the `eql_v1.add_index` function:
194+
Add an index to an encrypted column using the `eql_v2.add_index` function:
195195

196196
```sql
197-
SELECT eql_v1.add_index(
197+
SELECT eql_v2.add_index(
198198
'table_name', -- Name of the table
199199
'column_name', -- Name of the column
200200
'index_name', -- Index kind ('unique', 'match', 'ore', 'ste_vec')
@@ -208,7 +208,7 @@ You can read more about the index configuration options [here](docs/reference/IN
208208
**Example (Unique index):**
209209

210210
```sql
211-
SELECT eql_v1.add_index(
211+
SELECT eql_v2.add_index(
212212
'users',
213213
'encrypted_email',
214214
'unique',
@@ -219,8 +219,8 @@ SELECT eql_v1.add_index(
219219
After adding an index, you have to activate the configuration:
220220

221221
```sql
222-
SELECT eql_v1.encrypt();
223-
SELECT eql_v1.activate();
222+
SELECT eql_v2.encrypt();
223+
SELECT eql_v2.activate();
224224
```
225225

226226
## Searching data with EQL
@@ -231,12 +231,12 @@ In order to use the specialized functions, you must first configure the correspo
231231

232232
### Equality search
233233

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

236236
**Index configuration example:**
237237

238238
```sql
239-
SELECT eql_v1.add_index(
239+
SELECT eql_v2.add_index(
240240
'users',
241241
'encrypted_email',
242242
'unique',
@@ -248,7 +248,7 @@ SELECT eql_v1.add_index(
248248

249249
```sql
250250
SELECT * FROM users
251-
WHERE eql_v1.unique(encrypted_email) = eql_v1.unique(
251+
WHERE eql_v2.unique(encrypted_email) = eql_v2.unique(
252252
'{"v":1,"k":"pt","p":"[email protected]","i":{"t":"users","c":"encrypted_email"},"q":"unique"}'
253253
);
254254
```
@@ -261,12 +261,12 @@ SELECT * FROM users WHERE email = '[email protected]';
261261

262262
### Full-text search
263263

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

266266
**Index configuration example:**
267267

268268
```sql
269-
SELECT eql_v1.add_index(
269+
SELECT eql_v2.add_index(
270270
'users',
271271
'encrypted_email',
272272
'match',
@@ -279,7 +279,7 @@ SELECT eql_v1.add_index(
279279

280280
```sql
281281
SELECT * FROM users
282-
WHERE eql_v1.match(encrypted_email) @> eql_v1.match(
282+
WHERE eql_v2.match(encrypted_email) @> eql_v2.match(
283283
'{"v":1,"k":"pt","p":"test","i":{"t":"users","c":"encrypted_email"},"q":"match"}'
284284
);
285285
```
@@ -292,7 +292,7 @@ SELECT * FROM users WHERE email LIKE '%test%';
292292

293293
### Range queries
294294

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:
295+
Enable range queries on encrypted data using the `eql_v2.ore_64_8_v2`, `eql_v2.ore_cllw_u64_8`, or `eql_v2.ore_cllw_var_8` functions. Supports:
296296

297297
- `ORDER BY`
298298
- `WHERE`
@@ -301,7 +301,7 @@ Enable range queries on encrypted data using the `eql_v1.ore_64_8_v1`, `eql_v1.o
301301

302302
```sql
303303
SELECT * FROM users
304-
WHERE eql_v1.ore_64_8_v1(encrypted_date) < eql_v1.ore_64_8_v1(
304+
WHERE eql_v2.ore_64_8_v2(encrypted_date) < eql_v2.ore_64_8_v2(
305305
'{"v":1,"k":"pt","p":"2023-10-05","i":{"t":"users","c":"encrypted_date"},"q":"ore"}'
306306
);
307307
```
@@ -316,7 +316,7 @@ SELECT * FROM users WHERE date < '2023-10-05';
316316

317317
```sql
318318
SELECT id FROM users
319-
ORDER BY eql_v1.ore_64_8_v1(encrypted_field) DESC;
319+
ORDER BY eql_v2.ore_64_8_v2(encrypted_field) DESC;
320320
```
321321

322322
Equivalent plaintext query:
@@ -331,13 +331,13 @@ EQL supports array operations on encrypted data:
331331

332332
```sql
333333
-- Get array length
334-
SELECT eql_v1.jsonb_array_length(encrypted_array) FROM users;
334+
SELECT eql_v2.jsonb_array_length(encrypted_array) FROM users;
335335

336336
-- Get array elements
337-
SELECT eql_v1.jsonb_array_elements(encrypted_array) FROM users;
337+
SELECT eql_v2.jsonb_array_elements(encrypted_array) FROM users;
338338

339339
-- Get array element ciphertexts
340-
SELECT eql_v1.jsonb_array_elements_text(encrypted_array) FROM users;
340+
SELECT eql_v2.jsonb_array_elements_text(encrypted_array) FROM users;
341341
```
342342

343343
### JSON Path Operations
@@ -373,7 +373,7 @@ No, CipherStash Proxy is required to handle the encryption and decryption operat
373373

374374
### How is data encrypted in the database?
375375

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

379379
## Helper packages and examples

0 commit comments

Comments
 (0)