-
Notifications
You must be signed in to change notification settings - Fork 0
Rename search term for consistency #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35f7ad5
feat: rename match to bloom_filter
tobyhede bef9712
feat: remane blake3 field to b3
tobyhede d75a13b
feat: rename ore_64_8_v2 to ore_block_u64_8_256
tobyhede b87e438
feat: rename unique to hmac_256
tobyhede cb2b213
feat: rename ore directory as well
tobyhede 2679db6
feat: make it work
tobyhede File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,8 +148,8 @@ Data is stored in the PostgreSQL database as: | |
"t": "users" | ||
}, | ||
"k": "ct", | ||
"m": null, | ||
"o": null, | ||
"bf": null, | ||
"ob": null, | ||
"u": null, | ||
"v": 1 | ||
} | ||
|
@@ -231,7 +231,7 @@ In order to use the specialized functions, you must first configure the correspo | |
|
||
### Equality search | ||
|
||
Enable equality search on encrypted data using the `eql_v2.unique` function. | ||
Enable equality search on encrypted data using the `eql_v2.hmac_256` function. | ||
|
||
**Index configuration example:** | ||
|
||
|
@@ -248,8 +248,8 @@ SELECT eql_v2.add_search_config( | |
|
||
```sql | ||
SELECT * FROM users | ||
WHERE eql_v2.unique(encrypted_email) = eql_v2.unique( | ||
'{"v":1,"k":"pt","p":"[email protected]","i":{"t":"users","c":"encrypted_email"},"q":"unique"}' | ||
WHERE eql_v2.hmac_256(encrypted_email) = eql_v2.hmac_256( | ||
'{"v":1,"k":"pt","p":"[email protected]","i":{"t":"users","c":"encrypted_email"},"q":"hmac_256"}' | ||
); | ||
``` | ||
|
||
|
@@ -261,7 +261,7 @@ SELECT * FROM users WHERE email = '[email protected]'; | |
|
||
### Full-text search | ||
|
||
Enables basic full-text search on encrypted data using the `eql_v2.match` function. | ||
Enables basic full-text search on encrypted data using the `eql_v2.bloom_filter` function. | ||
|
||
**Index configuration example:** | ||
|
||
|
@@ -279,7 +279,7 @@ SELECT eql_v2.add_search_config( | |
|
||
```sql | ||
SELECT * FROM users | ||
WHERE eql_v2.match(encrypted_email) @> eql_v2.match( | ||
WHERE eql_v2.bloom_filter(encrypted_email) @> eql_v2.bloom_filter( | ||
'{"v":1,"k":"pt","p":"test","i":{"t":"users","c":"encrypted_email"},"q":"match"}' | ||
); | ||
``` | ||
|
@@ -292,7 +292,7 @@ SELECT * FROM users WHERE email LIKE '%test%'; | |
|
||
### Range queries | ||
|
||
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: | ||
Enable range queries on encrypted data using the `eql_v2.ore_block_u64_8_256`, `eql_v2.ore_cllw_u64_8`, or `eql_v2.ore_cllw_var_8` functions. Supports: | ||
|
||
- `ORDER BY` | ||
- `WHERE` | ||
|
@@ -301,7 +301,7 @@ Enable range queries on encrypted data using the `eql_v2.ore_64_8_v2`, `eql_v2.o | |
|
||
```sql | ||
SELECT * FROM users | ||
WHERE eql_v2.ore_64_8_v2(encrypted_date) < eql_v2.ore_64_8_v2( | ||
WHERE eql_v2.ore_block_u64_8_256(encrypted_date) < eql_v2.ore_block_u64_8_256( | ||
'{"v":1,"k":"pt","p":"2023-10-05","i":{"t":"users","c":"encrypted_date"},"q":"ore"}' | ||
); | ||
``` | ||
|
@@ -316,7 +316,7 @@ SELECT * FROM users WHERE date < '2023-10-05'; | |
|
||
```sql | ||
SELECT id FROM users | ||
ORDER BY eql_v2.ore_64_8_v2(encrypted_field) DESC; | ||
ORDER BY eql_v2.ore_block_u64_8_256(encrypted_field) DESC; | ||
``` | ||
|
||
Equivalent plaintext query: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,15 +193,15 @@ For ordering or comparison queries we add an `ore` index: | |
|
||
```sql | ||
SELECT cs_add_index_v2('users', 'email_encrypted', 'ore', 'text'); | ||
CREATE INDEX ON users (cs_ore_64_8_v2(email_encrypted)); | ||
CREATE INDEX ON users (ore_block_u64_8_256(email_encrypted)); | ||
``` | ||
|
||
After adding these indexes, our `eql_v2_configuration` table will look like this: | ||
|
||
```bash | ||
id | 1 | ||
state | pending | ||
data | {"v": 1, "tables": {"users": {"email_encrypted": {"cast_as": "text", "indexes": {"ore": {}, "match": {"k": 6, "m": 2048, "tokenizer": {"kind": "ngram", "token_length": 3}, "token_filters": [{"kind": "downcase"}], "include_original": true}, "unique": {"token_filters": [{"kind": "downcase"}]}}}}}} | ||
data | {"v": 1, "tables": {"users": {"email_encrypted": {"cast_as": "text", "indexes": {"ore": {}, "match": {"k": 6, "bf": 2048, "tokenizer": {"kind": "ngram", "token_length": 3}, "token_filters": [{"kind": "downcase"}], "include_original": true}, "unique": {"token_filters": [{"kind": "downcase"}]}}}}}} | ||
``` | ||
|
||
The initial `state` will be set as pending. | ||
|
@@ -218,7 +218,7 @@ The `cs_configured_v2` table will now have a state of `active`. | |
```bash | ||
id | 1 | ||
state | active | ||
data | {"v": 1, "tables": {"users": {"email_encrypted": {"cast_as": "text", "indexes": {"ore": {}, "match": {"k": 6, "m": 2048, "tokenizer": {"kind": "ngram", "token_length": 3}, "token_filters": [{"kind": "downcase"}], "include_original": true}, "unique": {"token_filters": [{"kind": "downcase"}]}}}}}} | ||
data | {"v": 1, "tables": {"users": {"email_encrypted": {"cast_as": "text", "indexes": {"ore": {}, "match": {"k": 6, "bf": 2048, "tokenizer": {"kind": "ngram", "token_length": 3}, "token_filters": [{"kind": "downcase"}], "include_original": true}, "unique": {"token_filters": [{"kind": "downcase"}]}}}}}} | ||
``` | ||
|
||
### Encrypting existing plaintext data | ||
|
@@ -325,9 +325,9 @@ It creates an EQL payload that looks similar to this and inserts this into the e | |
"t": "users", // Table | ||
"c": "email_encrypted" // Encrypted column | ||
}, | ||
"m": [42], // The ciphertext used for free text queries i.e match index | ||
"bf": [42], // The ciphertext used for free text queries i.e match index | ||
"u": "unique ciphertext", // The ciphertext used for unique queries. i.e unique index | ||
"o": ["a", "b", "c"], // The ciphertext used for order or comparison queries. i.e ore index | ||
"ob": ["a", "b", "c"], // The ciphertext used for order or comparison queries. i.e ore index | ||
"v": 1 | ||
} | ||
``` | ||
|
@@ -386,9 +386,9 @@ The json stored in the database looks similar to this: | |
"t": "users", // Table | ||
"c": "email_encrypted" // Encrypted column | ||
}, | ||
"m": [42], // The ciphertext used for free text queries i.e match index | ||
"bf": [42], // The ciphertext used for free text queries i.e match index | ||
"u": "unique ciphertext", // The ciphertext used for unique queries. i.e unique index | ||
"o": ["a", "b", "c"], // The ciphertext used for order or comparison queries. i.e ore index | ||
"ob": ["a", "b", "c"], // The ciphertext used for order or comparison queries. i.e ore index | ||
"v": 1 | ||
} | ||
``` | ||
|
@@ -509,7 +509,7 @@ Prerequsites: | |
|
||
- An [ore index](#adding-indexes) is needed on the encrypted column to support this operation. | ||
|
||
EQL function to use: `cs_ore_64_8_v2(val JSONB)`. | ||
EQL function to use: `ore_block_u64_8_256(val JSONB)`. | ||
|
||
A plaintext query order by email looks like this: | ||
|
||
|
@@ -520,7 +520,7 @@ SELECT * FROM users ORDER BY email ASC; | |
The EQL equivalent of this query is: | ||
|
||
```sql | ||
SELECT * FROM users ORDER BY cs_ore_64_8_v2(email_encrypted) ASC; | ||
SELECT * FROM users ORDER BY ore_block_u64_8_256(email_encrypted) ASC; | ||
``` | ||
|
||
This query returns: | ||
|
@@ -538,7 +538,7 @@ Prerequsites: | |
|
||
- A [unique index](#adding-indexes) is needed on the encrypted column to support this operation. | ||
|
||
EQL function to use: `cs_ore_64_8_v2(val JSONB)`. | ||
EQL function to use: `ore_block_u64_8_256(val JSONB)`. | ||
|
||
EQL query payload for a comparison query: | ||
|
||
|
@@ -564,7 +564,7 @@ SELECT * FROM users WHERE email > '[email protected]'; | |
The EQL equivalent of this query is: | ||
|
||
```sql | ||
SELECT * FROM users WHERE cs_ore_64_8_v2(email_encrypted) > cs_ore_64_8_v2( | ||
SELECT * FROM users WHERE ore_block_u64_8_256(email_encrypted) > ore_block_u64_8_256( | ||
'{"v":1,"k":"pt","p":"[email protected]","i":{"t":"users","c":"email_encrypted"},"q":"ore"}' | ||
); | ||
``` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- REQUIRE: src/schema.sql | ||
|
||
|
||
-- extracts match index from an emcrypted column | ||
|
||
CREATE FUNCTION eql_v2.bloom_filter(val jsonb) | ||
RETURNS eql_v2.bloom_filter | ||
IMMUTABLE STRICT PARALLEL SAFE | ||
AS $$ | ||
BEGIN | ||
IF val ? 'bf' THEN | ||
RETURN ARRAY(SELECT jsonb_array_elements(val->'bf'))::eql_v2.bloom_filter; | ||
END IF; | ||
RAISE 'Expected a match index (bf) value in json: %', val; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
|
||
-- extracts unique index from an encrypted column | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this meant to be 'match'? |
||
|
||
CREATE FUNCTION eql_v2.bloom_filter(val eql_v2_encrypted) | ||
RETURNS eql_v2.bloom_filter | ||
IMMUTABLE STRICT PARALLEL SAFE | ||
AS $$ | ||
BEGIN | ||
RETURN (SELECT eql_v2.bloom_filter(val.data)); | ||
END; | ||
$$ LANGUAGE plpgsql; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- REQUIRE: src/schema.sql | ||
|
||
CREATE DOMAIN eql_v2.bloom_filter AS smallint[]; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like unnecessary spaces (and also in the lines below in this file)