Skip to content

Commit abe36d6

Browse files
authored
Merge pull request #75 from cipherstash/kateandrews-eql-docs-edits
EQL docs edits
2 parents 0b160c0 + 2f86845 commit abe36d6

File tree

5 files changed

+66
-84
lines changed

5 files changed

+66
-84
lines changed

docs/README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
# EQL Documentation
1+
# EQL documentation
22

33
This directory contains the documentation for the Encrypt Query Language (EQL).
44

5-
## Concepts
5+
## About
66

7-
The following concepts are available:
7+
- [Postgres data security with CipherStash](concepts/WHY.md)
88

9-
- [Why we built EQL](concepts/WHY.md)
9+
## How-to guides
1010

11-
## Reference
11+
- [Getting started](tutorials/GETTINGSTARTED.md)
12+
- [Using CipherStash Proxy](tutorials/PROXY.md)
1213

13-
The following reference guides are available:
14+
## Reference
1415

1516
- [EQL index configuration](reference/INDEX.md)
16-
- [JSONB and JSON support](reference/JSON.md)
17-
- [Migrating plaintext data](reference/MIGRATOR.md)
17+
- [EQL with JSON and JSONB](reference/JSON.md)
18+
- [CipherStash Migrator](reference/MIGRATOR.md)
1819
- [EQL payload data format](reference/PAYLOAD.md)
19-
20-
## Tutorials
21-
22-
The following tutorials are available:
23-
24-
- [Getting started](tutorials/GETTINGSTARTED.md)
25-
- [Using CipherStash Proxy](tutorials/PROXY.md)

docs/concepts/WHY.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# Postgres data security with CipherStash
22

3-
This article gives a high-level overview of CipherStash's encryption in use solution, including the CipherStash Proxy and the Encrypt Query Language (EQL).
3+
This page gives a high-level overview of CipherStash's encryption in use solution, including CipherStash Proxy and the Encrypt Query Language (EQL). It's designed for developers and engineers who need to implement robust data security in PostgreSQL without sacrificing performance or usability.
44

5-
It is designed for developers and engineers who need to implement robust data security in PostgreSQL without sacrificing performance or usability.
6-
7-
## Table of Contents
5+
## On this page
86

97
1. [Encryption in use](#encryption-in-use)
108
- [What is encryption in use?](#what-is-encryption-in-use)
119
- [Why use encryption in use?](#why-use-encryption-in-use)
1210
2. [CipherStash Proxy](#cipherstash-proxy)
13-
- [Proxy overview](#proxy-overview)
1411
- [How it works](#how-it-works)
1512
3. [Encrypt Query Language (EQL)](#encrypt-query-language-eql)
1613
4. [Best practices](#best-practices)
@@ -20,7 +17,8 @@ It is designed for developers and engineers who need to implement robust data se
2017

2118
## Encryption in use
2219

23-
EQL enables encryption in use, without significant changes to your application code.
20+
CipherStash's encryption in use solution, comprising CipherStash Proxy and EQL, provides a practical way to enhance data security in Postgres databases.
21+
EQL enables encryption in use without significant changes to your application code.
2422
A variety of searchable encryption techniques are available, including:
2523

2624
- **Matching** - Equality or partial matches
@@ -44,8 +42,6 @@ Encryption in use mitigates this risk by ensuring that:
4442

4543
## CipherStash Proxy
4644

47-
### Proxy overview
48-
4945
CipherStash Proxy is a transparent proxy that sits between your application and your PostgreSQL database.
5046
It intercepts SQL queries and handles the encryption and decryption of data on-the-fly.
5147
This enables encryption in use without significant changes to your application code.
@@ -63,19 +59,19 @@ This enables encryption in use without significant changes to your application c
6359
Encrypt Query Language (EQL) is a set of PostgreSQL functions and data types provided by CipherStash to work with encrypted data and indexes.
6460
EQL allows you to perform queries on encrypted data without decrypting it, supporting operations like equality checks, range queries, and unique constraints.
6561

66-
To get started, view the [Getting Started](https://github.com/cipherstash/encrypt-query-language/blob/main/GETTINGSTARTED.md) guide.
62+
To get started, read the [Getting started](https://github.com/cipherstash/encrypt-query-language/blob/main/GETTINGSTARTED.md) guide.
6763

68-
## Best Practices
64+
## Best practices
6965

70-
- **Leverage CipherStash Proxy**: Use CipherStash Proxy to handle encryption/decryption transparently.
71-
- **Utilize EQL functions**: Always use EQL functions when interacting with encrypted data.
72-
- **Define constraints**: Apply database constraints to maintain data integrity.
73-
- **Secure key management**: Ensure encryption keys are securely managed and stored.
74-
- **Monitor performance**: Keep an eye on query performance and optimize as needed.
66+
- **Use CipherStash Proxy** to handle encryption/decryption transparently.
67+
- **Use EQL functions** when interacting with encrypted data.
68+
- **Define database constraints**to maintain data integrity.
69+
- **Secure key management** of encryption keys.
70+
- **Monitor query performance** and optimize as needed.
7571

76-
## Advanced Topics
72+
## Advanced topics
7773

78-
### Integrating without CipehrStash Proxy
74+
### Integrating without CipherStash Proxy
7975

8076
> The SDK approach is currently in development, but if you're interested in contributing, please start a discussion [here](https://github.com/cipherstash/encrypt-query-language/discussions).
8177
@@ -88,11 +84,8 @@ For advanced users who prefer to handle encryption within their application:
8884

8985
**Note**: This approach increases complexity and is recommended only if CipherStash Proxy does not meet specific requirements.
9086

91-
## Conclusion
92-
93-
CipherStash's encryption in use solution, comprising CipherStash Proxy and EQL, provides a practical way to enhance data security in Postgres databases.
94-
By keeping data encrypted even during processing, you minimize the risk of data breaches and comply with stringent security standards without significant changes to your application logic.
87+
## Getting started
9588

96-
To get started, see the [Getting Started](https://github.com/cipherstash/encrypt-query-language/blob/main/GETTINGSTARTED.md) guide.
89+
To get started using CipherStash's encryption is use solution, see the [Getting Started](https://github.com/cipherstash/encrypt-query-language/blob/main/GETTINGSTARTED.md) guide.
9790

98-
**Contact Support:** For further assistance, raise an issue [here](https://github.com/cipherstash/encrypt-query-language/issues).
91+
For further help, raise an issue [here](https://github.com/cipherstash/encrypt-query-language/issues).

docs/reference/INDEX.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# EQL index configuration
22

33
The following functions allow you to configure indexes for encrypted columns.
4-
All these functions modify the `cs_configuration_v1` table in your database, and is added during the EQL installation.
4+
All these functions modify the `cs_configuration_v1` table in your database, and are added during the EQL installation.
55

66
> **IMPORTANT:** When you modify or add an index, you must re-encrypt data that's already been stored in the database.
77
The CipherStash encryption solution will encrypt the data based on the current state of the configuration.
@@ -24,7 +24,7 @@ SELECT cs_add_index_v1(
2424
| ------------- | -------------------------------------------------- | ------------------------------------------------------------------------ |
2525
| `table_name` | Name of target table | Required |
2626
| `column_name` | Name of target column | Required |
27-
| `index_name` | The index kind | Required. |
27+
| `index_name` | The index kind | Required |
2828
| `cast_as` | The PostgreSQL type decrypted data will be cast to | Optional. Defaults to `text` |
2929
| `opts` | Index options | Optional for `match` indexes, required for `ste_vec` indexes (see below) |
3030

@@ -44,7 +44,7 @@ Supported types:
4444

4545
A match index enables full text search across one or more text fields in queries.
4646

47-
The default Match index options are:
47+
The default match index options are:
4848

4949
```json
5050
{
@@ -93,21 +93,21 @@ Specifically, searching for strings _shorter_ than the `tokenLength` parameter w
9393

9494
If you're using n-gram as a token filter, then a token that is already shorter than the `tokenLength` parameter will be kept as-is when indexed, and so a search for that short token will match that record.
9595
However, if that same short string only appears as a part of a larger token, then it will not match that record.
96-
In general, therefore, you should try to ensure that the string you search for is at least as long as the `tokenLength` of the index, except in the specific case where you know that there are shorter tokens to match, _and_ you are explicitly OK with not returning records that have that short string as part of a larger token.
96+
Try to ensure that the string you search for is at least as long as the `tokenLength` of the index, except in the specific case where you know that there are shorter tokens to match, _and_ you are explicitly OK with not returning records that have that short string as part of a larger token.
9797

9898
#### Options for ste_vec indexes (`opts`)
9999

100100
An ste_vec index on a encrypted JSONB column enables the use of PostgreSQL's `@>` and `<@` [containment operators](https://www.postgresql.org/docs/16/functions-json.html#FUNCTIONS-JSONB-OP-TABLE).
101101

102102
An ste_vec index requires one piece of configuration: the `context` (a string) which is passed as an info string to a MAC (Message Authenticated Code).
103103
This ensures that all of the encrypted values are unique to that context.
104-
It is generally recommended to use the table and column name as a the context (e.g. `users/name`).
104+
We recommend that you use the table and column name as a the context (e.g. `users/name`).
105105

106-
Within a dataset, encrypted columns indexed using an `ste_vec` that use different contexts cannot be compared.
106+
Within a dataset, encrypted columns indexed using an `ste_vec` that use different contexts can't be compared.
107107
Containment queries that manage to mix index terms from multiple columns will never return a positive result.
108108
This is by design.
109109

110-
The index is generated from a JSONB document by first flattening the structure of the document such that a hash can be generated for each unique path prefix to a node.
110+
The index is generated from a JSONB document by first flattening the structure of the document so that a hash can be generated for each unique path prefix to a node.
111111

112112
The complete set of JSON types is supported by the indexer.
113113
Null values are ignored by the indexer.
@@ -182,7 +182,7 @@ The hashes would be generated for all prefixes of the full path to the leaf node
182182

183183
Query terms are processed in the same manner as the input document.
184184

185-
A query prior to encrypting & indexing looks like a structurally similar subset of the encrypted document, for example:
185+
A query prior to encrypting and indexing looks like a structurally similar subset of the encrypted document. For example:
186186

187187
```json
188188
{
@@ -238,4 +238,4 @@ SELECT cs_remove_index_v1(
238238
column_name text,
239239
index_name text
240240
);
241-
```
241+
```

docs/reference/JSON.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
EQL supports encrypting, decrypting, and searching JSON and JSONB objects.
44

5-
## Table of contents
6-
7-
- [Configuring the Index](#configuring-the-index)
8-
- [Inserting JSON Data](#inserting-json-data)
9-
- [Reading JSON Data](#reading-json-data)
10-
- [Querying JSONB Data with EQL](#querying-jsonb-data-with-eql)
11-
- [Containment Queries (`cs_ste_vec_v1`)](#containment-queries-cs_ste_vec_v1)
12-
- [Field Extraction (`cs_ste_vec_value_v1`)](#field-extraction-cs_ste_vec_value_v1)
13-
- [Field Comparison (`cs_ste_vec_term_v1`)](#field-comparison-cs_ste_vec_term_v1)
14-
- [Grouping Data](#grouping-data)
15-
- [Reference](#reference)
16-
- [EQL Functions for JSONB and `ste_vec`](#eql-functions-for-jsonb-and-ste_vec)
17-
- [EJSON Paths](#ejson-paths)
18-
- [Native PostgreSQL JSON(B) Compared to EQL](#native-postgresql-jsonb-compared-to-eql)
5+
## On this page
6+
7+
- [Configuring the index](#configuring-the-index)
8+
- [Inserting JSON data](#inserting-json-data)
9+
- [Reading JSON data](#reading-json-data)
10+
- [Querying JSONB data with EQL](#querying-jsonb-data-with-eql)
11+
- [Containment queries (`cs_ste_vec_v1`)](#containment-queries-cs_ste_vec_v1)
12+
- [Field extraction (`cs_ste_vec_value_v1`)](#field-extraction-cs_ste_vec_value_v1)
13+
- [Field comparison (`cs_ste_vec_term_v1`)](#field-comparison-cs_ste_vec_term_v1)
14+
- [Grouping data](#grouping-data)
15+
- [EQL functions for JSONB and `ste_vec`](#eql-functions-for-jsonb-and-ste_vec)
16+
- [EJSON paths](#ejson-paths)
17+
- [Native PostgreSQL JSON(B) compared to EQL](#native-postgresql-jsonb-compared-to-eql)
1918
- [`json ->> text``text` and `json -> text``jsonb`/`json`](#json--text--text-and-json---text--jsonbjson)
2019
- [Decryption Example](#decryption-example)
2120
- [Comparison Example](#comparison-example)
@@ -116,15 +115,15 @@ Data is returned as:
116115
}
117116
```
118117

119-
## Querying JSONB Data with EQL
118+
## Querying JSONB data with EQL
120119

121120
EQL provides specialized functions to interact with encrypted JSONB data, supporting operations like containment queries, field extraction, and comparisons.
122121

123-
### Containment Queries (`cs_ste_vec_v1`)
122+
### Containment queries (`cs_ste_vec_v1`)
124123

125124
Retrieve the Structured Encryption Vector for JSONB containment queries.
126125

127-
**Example: Containment Query**
126+
**Example: Containment query**
128127

129128
Suppose we have the following encrypted JSONB data:
130129

@@ -138,7 +137,7 @@ Suppose we have the following encrypted JSONB data:
138137

139138
We can query records that contain a specific structure.
140139

141-
**SQL Query:**
140+
**SQL query:**
142141

143142
```sql
144143
SELECT * FROM examples
@@ -162,11 +161,11 @@ WHERE jsonb_column @> '{"top":{"nested":["a"]}}';
162161

163162
**Note:** The `@>` operator checks if the left JSONB value contains the right JSONB value.
164163

165-
**Negative Example:**
164+
**Negative example:**
166165

167166
If we query for a value that does not exist in the data:
168167

169-
**SQL Query:**
168+
**SQL query:**
170169

171170
```sql
172171
SELECT * FROM examples
@@ -183,7 +182,7 @@ WHERE cs_ste_vec_v1(encrypted_json) @> cs_ste_vec_v1(
183182

184183
This query would return no results, as the value `"d"` is not present in the `"nested"` array.
185184

186-
### Field Extraction (`cs_ste_vec_value_v1`)
185+
### Field extraction (`cs_ste_vec_value_v1`)
187186

188187
Extract a field from an encrypted JSONB object.
189188

@@ -201,7 +200,7 @@ Suppose we have the following encrypted JSONB data:
201200

202201
We can extract the value of the `"top"` key.
203202

204-
**SQL Query:**
203+
**SQL query:**
205204

206205
```sql
207206
SELECT cs_ste_vec_value_v1(encrypted_json,
@@ -231,7 +230,7 @@ FROM examples;
231230
}
232231
```
233232

234-
### Field Comparison (`cs_ste_vec_term_v1`)
233+
### Field comparison (`cs_ste_vec_term_v1`)
235234

236235
Select rows based on a field value in an encrypted JSONB object.
237236

@@ -247,7 +246,7 @@ Suppose we have encrypted JSONB data with a numeric field:
247246

248247
We can query records where the `"num"` field is greater than `2`.
249248

250-
**SQL Query:**
249+
**SQL query:**
251250

252251
```sql
253252
SELECT * FROM examples
@@ -277,7 +276,7 @@ SELECT * FROM examples
277276
WHERE (jsonb_column->>'num')::int > 2;
278277
```
279278

280-
### Grouping Data
279+
### Grouping data
281280

282281
Use `cs_ste_vec_term_v1` along with `cs_grouped_value_v1` to group by a field in an encrypted JSONB column.
283282

@@ -296,7 +295,7 @@ Suppose we have records with a `"color"` field:
296295

297296
We can group the data by the `"color"` field and count occurrences.
298297

299-
**SQL Query:**
298+
**SQL query:**
300299

301300
```sql
302301
SELECT cs_grouped_value_v1(cs_ste_vec_value_v1(encrypted_json,
@@ -336,24 +335,22 @@ GROUP BY jsonb_column->>'color';
336335
| green | 2 |
337336
| red | 1 |
338337

339-
## Reference
338+
## EQL Functions for JSONB and `ste_vec`
340339

341-
### EQL Functions for JSONB and `ste_vec`
342-
343-
- **Index Management**
340+
- **Index management**
344341

345342
- `cs_add_index_v1(table_name text, column_name text, 'ste_vec', 'jsonb', opts jsonb)`: Adds an `ste_vec` index configuration.
346343
- `opts` must include the `"context"` key.
347344

348-
- **Query Functions**
345+
- **Query functions**
349346

350347
- `cs_ste_vec_v1(val jsonb)`: Retrieves the STE vector for JSONB containment queries.
351348
- `cs_ste_vec_term_v1(val jsonb, epath jsonb)`: Retrieves the encrypted term associated with an encrypted JSON path.
352349
- `cs_ste_vec_value_v1(val jsonb, epath jsonb)`: Retrieves the decrypted value associated with an encrypted JSON path.
353350
- `cs_ste_vec_terms_v1(val jsonb, epath jsonb)`: Retrieves an array of encrypted terms for elements in an array at the given JSON path (used for comparisons).
354351
- `cs_grouped_value_v1(val jsonb)`: Used with `ste_vec` indexes for grouping.
355352

356-
### EJSON Paths
353+
## EJSON paths
357354

358355
EQL uses an extended JSONPath syntax called EJSONPath for specifying paths in JSONB data.
359356

@@ -363,7 +360,7 @@ EQL uses an extended JSONPath syntax called EJSONPath for specifying paths in JS
363360
- Wildcards are supported: `$.some_array_field[*]`
364361
- Array indexing is **not** supported: `$.some_array_field[0]`
365362

366-
**Example Paths:**
363+
**Example paths:**
367364

368365
- `$.top.nested` selects the `"nested"` key within the `"top"` object.
369366
- `$.array[*]` selects all elements in the `"array"` array.

docs/reference/MIGRATOR.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# CipherStash Migrator
22

3-
The CipherStash Migrator is a tool that can be used to migrate plaintext data in a database to its encrypted equivalent.
3+
CipherStash Migrator is a tool that can be used to migrate plaintext data in a database to its encrypted equivalent.
44
It works inside the CipherStash Proxy Docker container and can handle different data types such as text, JSONB, integers, booleans, floats, and dates.
5-
By specifying the relevant columns in your table, the migrator will seamlessly encrypt the existing data and store it in designated encrypted columns.
5+
By specifying the relevant columns in your table, CipherStash Migrator will seamlessly encrypt the existing data and store it in designated encrypted columns.
66

77
## Prerequisites
88

99
- [CipherStash Proxy](PROXY.md)
1010
- [Have set up EQL in your database](GETTINGSTARTED.md)
1111
- Ensure that the columns where data will be migrated already exist.
1212

13-
Here’s a draft for the technical usage documentation for the CipherStash Migrator tool:
14-
1513
## Usage
1614

1715
The CipherStash Migrator allows you to specify key-value pairs where the key is the plaintext column, and the value is the corresponding encrypted column.

0 commit comments

Comments
 (0)