Skip to content

Commit d5e660d

Browse files
authored
Merge pull request #1241 from cipherstash/feat/eql-v4-equality-types
feat(eql-bindings): produce IntegerEq, BigintEq, RealEq and DoubleEq, and name each type's real blocker
2 parents 3a21644 + 863240d commit d5e660d

39 files changed

Lines changed: 1266 additions & 911 deletions

‎.changeset/eql-v4-bindings.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
'@cipherstash/eql': minor
33
---
44

5-
**The `eql-bindings` crate has an `eql_bindings::v4` module: payload types for the EQL v4 domains.** EQL v4 is the v3 SQL installed under a second name (ADR-0002), for values written by Stack Encrypt. The module is generated from the same catalog as `v3`, with `eql_v4_*` domain names and `"v": 4`. `SchemaVersion` is now generic over the version it admits: `v3::SchemaVersion` is `SchemaVersion<3>` and `v4::SchemaVersion` is `SchemaVersion<4>`, each refusing the other's payloads, and plain `SchemaVersion` still means v3. Only v4 types derive Stack Encrypt's `EncryptFrom` and `DecryptInto`, and the Stack Encrypt target table (now `eql_bindings::v4::targets`) names v4 domains. Besides `TextEq`, Stack Encrypt now produces the storage-only types `Text`, `Integer`, `Bigint`, `Boolean`, `Real` and `Double`, and `TextMatch` (3-grams, `k = 6`, a 2048-bit filter, pinned as `eql_bindings::encryption::EqlMatch`; text shorter than three characters is refused, stored or queried, and only `stored @@ query` matches until #1171 is fixed), from the plaintext types in `eql_bindings::encryption::plaintext`; the Go SDK's `encrypt/eql` table marks them producible. `IntegerEq` and `BigintEq` stay unproducible until vitaminc 0.6 settles the integer equality term.
5+
**The `eql-bindings` crate has an `eql_bindings::v4` module, with the `stack-encrypt` feature: payload types for the EQL v4 domains.** EQL v4 is the v3 SQL installed under a second name (ADR-0002), for values written by Stack Encrypt, so the module exists only with that feature and its types derive Stack Encrypt's traits without a further gate. The module is generated from the same catalog as `v3`, with `eql_v4_*` domain names and `"v": 4`. `SchemaVersion` is now generic over the version it admits: `v3::SchemaVersion` is `SchemaVersion<3>` and `v4::SchemaVersion` is `SchemaVersion<4>`, each refusing the other's payloads, and plain `SchemaVersion` still means v3. Only v4 types derive Stack Encrypt's `EncryptFrom` and `DecryptInto`, and the Stack Encrypt target table (now `eql_bindings::v4::targets`) names v4 domains. Besides `TextEq`, Stack Encrypt now produces the storage-only types `Text`, `Integer`, `Bigint`, `Boolean`, `Real` and `Double`, and `TextMatch` (3-grams, `k = 6`, a 2048-bit filter, pinned as `eql_bindings::encryption::EqlMatch`; text shorter than three characters is refused, stored or queried, and only `stored @@ query` matches until #1171 is fixed), from the Rust primitives `i32`, `i64`, `bool`, `f32` and `f64`; the Go SDK's `encrypt/eql` table marks them producible. Stack Encrypt also produces the number equality types `IntegerEq`, `BigintEq`, `RealEq` and `DoubleEq`, whose `=` compares as PostgreSQL compares the plain types: an integer has one term whatever its width, and for floats `-0.0 = 0.0` and `NaN = NaN` (ADR-0002's semantic baseline). Every type it cannot produce yet names the issue that tracks its blocker.
66

77
Nothing a released version shipped has changed. The v3 types, the v3 SQL and the TypeScript package are as they were; the `stack-encrypt` derives on the v3 text types and the `v3::targets` module were added after the last release and are moved to v4 here, not removed from a release.

‎languages/golang/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ listed under **Breaking**. Releases are tagged `languages/golang/vX.Y.Z`.
4141
NULL.
4242
- **`encrypt.Range`**: what `Between` returns, the low and high bound's
4343
terms.
44+
- **`IntegerEq`, `BigintEq`, `RealEq` and `DoubleEq`**: an `int32`, `int64`,
45+
`float32` or `float64` field tagged `encrypt_into=` one of them gets `Eq`.
46+
`=` compares as PostgreSQL compares the plain types: an integer has one
47+
term whatever its width, and for floats `-0.0 = 0.0` and `NaN = NaN`.
4448
- **stashgen notices an index no generated method queries**: an `ore` or
4549
`ope` index on text, bytes or a float (the engine answers the orderings
4650
over integers only), or the second of two order indexes on an integer.
@@ -53,3 +57,5 @@ listed under **Breaking**. Releases are tagged `languages/golang/vX.Y.Z`.
5357
checked by decrypting them, and such a field stores no ciphertext.
5458
- A query with a nil cipher returns `ErrEncoding` from generated code as from
5559
the library.
60+
- stashgen's refusal of an EQL type it cannot produce names the issue that
61+
tracks the blocker, in place of telling you to wait for vitaminc 0.6.

‎languages/golang/cmd/stashgen/README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ The engine produces these EQL types today, each from one Go field type:
159159
| `encrypt_into` | Go field |
160160
|---|---|
161161
| `TextEq`, `Text`, `TextMatch` | `string` |
162-
| `Integer` | `int32` |
163-
| `Bigint` | `int64` |
162+
| `Integer`, `IntegerEq` | `int32` |
163+
| `Bigint`, `BigintEq` | `int64` |
164164
| `Boolean` | `bool` |
165-
| `Real` | `float32` |
166-
| `Double` | `float64` |
165+
| `Real`, `RealEq` | `float32` |
166+
| `Double`, `DoubleEq` | `float64` |
167+
168+
The `Eq` types answer `Eq`; `Text`, `Integer`, `Bigint`, `Boolean`, `Real` and `Double` are stored and read only, with no query method.
167169

168170
The width must match: an `int` or `int64` field is not an `Integer`, and a `float64` field is not a `Real`.
169171
A `TextMatch` field refuses text shorter than three characters, such as an empty string or a two-letter code, because it has no 3-grams to index; its query refuses such text too.

‎languages/golang/encrypt/README.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,20 @@ The EQL types the engine produces, and the Go field types each takes:
399399
| `TextMatch` | `string` | `@@` (substring match, 3-grams, case-insensitive) |
400400
| `Text` | `string` | none: stored and read only |
401401
| `Integer` | `int32` | none |
402+
| `IntegerEq` | `int32` | `=`, `<>` |
402403
| `Bigint` | `int64` | none |
404+
| `BigintEq` | `int64` | `=`, `<>` |
403405
| `Boolean` | `bool` | none |
404406
| `Real` | `float32` | none |
407+
| `RealEq` | `float32` | `=`, `<>` |
405408
| `Double` | `float64` | none |
409+
| `DoubleEq` | `float64` | `=`, `<>` |
406410

407411
A `TextMatch` value must be at least three characters long: shorter text has
408-
no 3-grams to index and is refused. `IntegerEq` and `BigintEq` are held back
409-
until the engine's integer equality term settles in vitaminc 0.6. The rest of
412+
no 3-grams to index and is refused. The number equality types compare as
413+
PostgreSQL compares the plain types: an integer equals itself whatever its
414+
width, and for floats `-0.0 = 0.0` and `NaN = NaN`; the stored value still
415+
decrypts to exactly what was written. The rest of
410416
the catalog (ordering, dates, decimals, JSON) is listed in
411417
`eql.Types` with the reason it is not produced yet, and `stashgen` refuses it
412418
with that reason. The guest builds the value: the generated code

‎languages/golang/encrypt/doc.go‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
// }
2222
//
2323
// encrypt_into names the EQL type the field is stored as. The Go field type
24-
// must match it: TextEq, TextMatch and Text take a string, Integer an int32,
25-
// Bigint an int64, Boolean a bool, Real a float32 and Double a float64.
24+
// must match it: TextEq, TextMatch and Text take a string, Integer and
25+
// IntegerEq an int32, Bigint and BigintEq an int64, Boolean a bool, Real and
26+
// RealEq a float32, and Double and DoubleEq a float64. The *Eq types answer
27+
// Eq; Integer, Bigint, Boolean, Real, Double and Text are stored and read
28+
// only.
2629
//
2730
// 3. Run the generator. It writes user_stash.go beside the struct:
2831
//

0 commit comments

Comments
 (0)