Skip to content

Commit b87e438

Browse files
committed
feat: rename unique to hmac_256
1 parent d75a13b commit b87e438

18 files changed

+31
-444
lines changed

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ Each type of encrypted index (`unique`, `match`, `ore`) has an associated type,
318318
These are transient runtime types, used internally by EQL functions and operators:
319319

320320
- `eql_v2.blake3`
321-
- `eql_v2.unique_index`
321+
- `eql_v2.hmac_256`
322322
- `eql_v2.bloom_filter`
323323
- `eql_v2.ore_cllw_u64_8`
324324
- `eql_v2.ore_cllw_var_8`

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ 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_v2.unique` function.
234+
Enable equality search on encrypted data using the `eql_v2.hmac_256` function.
235235

236236
**Index configuration example:**
237237

@@ -248,8 +248,8 @@ SELECT eql_v2.add_search_config(
248248

249249
```sql
250250
SELECT * FROM users
251-
WHERE eql_v2.unique(encrypted_email) = eql_v2.unique(
252-
'{"v":1,"k":"pt","p":"test@example.com","i":{"t":"users","c":"encrypted_email"},"q":"unique"}'
251+
WHERE eql_v2.hmac_256(encrypted_email) = eql_v2.hmac_256(
252+
'{"v":1,"k":"pt","p":"test@example.com","i":{"t":"users","c":"encrypted_email"},"q":"hmac_256"}'
253253
);
254254
```
255255

SUPABASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In EQL, PostgreSQL operators are an alias for a function, so the implementation
2828
| --------------------------------- | --------------------------------------------------------- | ----------------------------------------------- |
2929
| `eql_v2.ciphertext(val)` | Extract ciphertext from encrypted value | `SELECT eql_v2.ciphertext (encrypted_field)` |
3030
| `eql_v2.blake3(val)` | Extract blake3 hash from encrypted value | `SELECT eql_v2.blake3( encrypted_field)` |
31-
| `eql_v2.unique(val)` | Extract unique index from encrypted value | `SELECT eql_v2.unique(encrypted_fie ld)` |
31+
| `eql_v2.hmac_256(val)` | Extract hmac_256 index from encrypted value | `SELECT eql_v2.hmac_256(encrypted_fie ld)` |
3232
| `eql_v2.bloom_filter(val)` | Extract match index from encrypted value | `SELECT eql_v2.bloom_filter(encrypted_field)` |
3333
| `eql_v2.ore_block_u64_8_256(val)` | Extract ORE index from encrypted value | `SELECT eql_v2.ore_block_u64_8_256(encrypted_field)` |
3434
| `eql_v2.ore_cllw_u64_8(val)` | Extract CLLW ORE index from encrypted value | `SELECT eql_v2.ore_cllw_u64_8(encrypted_fie ld)` |

src/encrypted/functions.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- REQUIRE: src/encrypted/types.sql
2-
-- REQUIRE: src/match/types.sql
2+
-- REQUIRE: src/bloom_filter/types.sql
33
-- REQUIRE: src/ore/types.sql
44
-- REQUIRE: src/unique/types.sql
55

src/unique/functions.sql renamed to src/hmac_256/functions.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
-- extracts unique index from an encrypted column
55

6-
CREATE FUNCTION eql_v2.unique(val jsonb)
7-
RETURNS eql_v2.unique_index
6+
CREATE FUNCTION eql_v2.hmac_256(val jsonb)
7+
RETURNS eql_v2.hmac_256
88
IMMUTABLE STRICT PARALLEL SAFE
99
AS $$
1010
BEGIN
@@ -18,12 +18,12 @@ $$ LANGUAGE plpgsql;
1818

1919
-- extracts unique index from an encrypted column
2020

21-
CREATE FUNCTION eql_v2.unique(val eql_v2_encrypted)
22-
RETURNS eql_v2.unique_index
21+
CREATE FUNCTION eql_v2.hmac_256(val eql_v2_encrypted)
22+
RETURNS eql_v2.hmac_256
2323
IMMUTABLE STRICT PARALLEL SAFE
2424
AS $$
2525
BEGIN
26-
RETURN (SELECT eql_v2.unique(val.data));
26+
RETURN (SELECT eql_v2.hmac_256(val.data));
2727
END;
2828
$$ LANGUAGE plpgsql;
2929

src/hmac_256/functions_test.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
\set ON_ERROR_STOP on
2+
3+
DO $$
4+
BEGIN
5+
PERFORM assert_result(
6+
'Extract hmac_256 index term from encrypted',
7+
'SELECT eql_v2.hmac_256(''{"u": "u"}''::jsonb)');
8+
9+
PERFORM assert_exception(
10+
'Missing hmac_256 index term in encrypted raises exception',
11+
'SELECT eql_v2.hmac_256(''{}''::jsonb)');
12+
13+
END;
14+
$$ LANGUAGE plpgsql;

src/hmac_256/types.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- REQUIRE: src/schema.sql
2+
3+
CREATE DOMAIN eql_v2.hmac_256 AS text;

src/operators/<.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ AS $$
2828

2929
BEGIN
3030
RETURN eql_v2.ore_cllw_u64_8(a) < eql_v2.ore_cllw_u64_8(b);
31-
-- RETURN (eql_v2.unique(a) = eql_v2.unique(b));
3231
EXCEPTION WHEN OTHERS THEN
3332
-- PERFORM eql_v2.log('eql_v2.lt no ore_cllw_u64_8 index');
3433
END;

src/operators/=.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
-- jsonb = eql_v2_encrypted
2020
--
2121
-- There are multiple index terms that provide equality comparisons
22-
-- - unique
23-
-- - ore_64_8_v2
2422
--
2523
--
2624
-- We check these index terms in this order and use the first one that exists for both parameters
@@ -35,7 +33,7 @@ AS $$
3533
BEGIN
3634

3735
BEGIN
38-
RETURN eql_v2.unique(a) = eql_v2.unique(b);
36+
RETURN eql_v2.hmac_256(a) = eql_v2.hmac_256(b);
3937
EXCEPTION WHEN OTHERS THEN
4038
-- PERFORM eql_v2.log('No unique index');
4139
END;

src/operators/~~.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- REQUIRE: src/schema.sql
22
-- REQUIRE: src/encrypted/types.sql
3-
-- REQUIRE: src/match/types.sql
4-
-- REQUIRE: src/match/functions.sql
3+
-- REQUIRE: src/bloom_filter/types.sql
4+
-- REQUIRE: src/bloom_filter/functions.sql
55

66
-- Operators for match comparisons of eql_v2_encrypted types
77
--

0 commit comments

Comments
 (0)