Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/eql-bindings-plaintext-by-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@cipherstash/eql': minor
---

**eql-bindings reads every plaintext in place** (`stack-encrypt` feature). The EQL v4 types seal and index a plaintext without copying it, so a plaintext no longer needs `Clone`.

- The `Ciphertext` and `Hmac256` targets, and the query twins, are bounded by `Encrypt + EncryptRef`, where they were bounded by `Encrypt + Clone`. A plaintext with only a by-value `Encrypt` impl adds `impl Encrypt for &T`.
- A query twin's plaintext is `Zeroize`, because a query hands its value to the index by value and wipes it.
- `v4::plaintext::Date`, `Timestamp`, and `Decimal` are Vitamin C's types, built from jiff's and rust_decimal's values. They are not `Clone`.
- The crate's `jiff` and `rust_decimal` features now only turn on `stack-encrypt`. That feature turns on both.
2 changes: 1 addition & 1 deletion .changeset/eql-v4-date-timestamp-numeric.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@cipherstash/eql': minor
---

**Stack Encrypt produces the EQL v4 date, timestamp and numeric types `Date`, `DateEq`, `Timestamp`, `TimestampEq`, `Numeric` and `NumericEq`** (`eql-bindings`, `stack-encrypt` feature). Their Rust plaintexts are Stack Encrypt's `stack_encrypt::value::Date`, `Timestamp` and `Decimal`, re-exported as `v4::plaintext::Date`, `Timestamp` and `Decimal`. They hold the integers the engine stores (days since 1970-01-01; Unix seconds and nanoseconds; a mantissa and a scale), are range checked when built and are wiped when dropped. eql-bindings' `jiff` and `rust_decimal` features turn on Stack Encrypt's features of the same names, which convert to and from those crates' types. Dates are from `-009999-01-01` to `9999-12-31`, and instants from `-009999-01-02T01:59:59Z` to `9999-12-30T22:00:00.999999999Z`. `=` on `NumericEq` normalises the scale (`1.5 = 1.50`) and on `TimestampEq` compares to the microsecond, truncating (never rounding) the nanoseconds below it; each value decrypts as it was stored. The Go SDK's `encrypt/eql` table marks the six producible, from `encrypt.Date`, `time.Time` and `encrypt.Decimal`.
**Stack Encrypt produces the EQL v4 date, timestamp and numeric types `Date`, `DateEq`, `Timestamp`, `TimestampEq`, `Numeric` and `NumericEq`** (`eql-bindings`, `stack-encrypt` feature). Their Rust plaintexts are Vitamin C's `Date`, `Timestamp` and `Decimal`, which `stack_encrypt::value` re-exports, re-exported again as `v4::plaintext::Date`, `Timestamp` and `Decimal`. A `Date` is built from a jiff `civil::Date`, a `Timestamp` from a jiff `Timestamp`, and a `Decimal` from a rust_decimal `Decimal`, and each is read back as that type. None is `Clone`, and each is wiped when it is dropped. The `stack-encrypt` feature turns on jiff and rust_decimal, so the three types exist whenever it is on. Dates are from `-009999-01-01` to `9999-12-31`, and instants from `-009999-01-02T01:59:59Z` to `9999-12-30T22:00:00.999999999Z`. `=` on `NumericEq` normalises the scale (`1.5 = 1.50`) and on `TimestampEq` compares to the microsecond, truncating (never rounding) the nanoseconds below it; each value decrypts as it was stored. The Go SDK's `encrypt/eql` table marks the six producible, from `encrypt.Date`, `time.Time` and `encrypt.Decimal`.
2 changes: 1 addition & 1 deletion .changeset/eql-v4-ordered-date-timestamp-numeric.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@cipherstash/eql': minor
---

**Stack Encrypt produces the EQL v4 ordered date, timestamp and numeric types** (`eql-bindings`, `stack-encrypt` feature): `DateOrd`, `DateOrdOpe`, `DateOrdOre`, `TimestampOrd`, `TimestampOrdOpe`, `TimestampOrdOre`, `NumericOrd`, `NumericOrdOpe` and `NumericOrdOre`. A date orders by its day, a timestamp by the microsecond (truncated, as `TimestampEq`'s `=` is) and a decimal by value, so `1.5` and `1.50` order as equal. `v4::plaintext::Date`, `Timestamp`, `Decimal` and `RangeError` are now Stack Encrypt's own types, re-exported at the same path. The Go SDK's `encrypt/eql` table marks the nine producible.
**Stack Encrypt produces the EQL v4 ordered date, timestamp and numeric types** (`eql-bindings`, `stack-encrypt` feature): `DateOrd`, `DateOrdOpe`, `DateOrdOre`, `TimestampOrd`, `TimestampOrdOpe`, `TimestampOrdOre`, `NumericOrd`, `NumericOrdOpe` and `NumericOrdOre`. A date orders by its day, a timestamp by the microsecond (truncated, as `TimestampEq`'s `=` is) and a decimal by value, so `1.5` and `1.50` order as equal. `v4::plaintext::Date`, `Timestamp` and `Decimal` are Vitamin C's types, re-exported through Stack Encrypt at the same path, with `OutOfRange` for a jiff `Timestamp` outside the range. The Go SDK's `encrypt/eql` table marks the nine producible.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ vitaminc-hmac = "0.10.0"
vitaminc-normalize = "0.10.0"
# The text order key: the system ADR-0002's fold, pinned to Unicode 16,
# which text ORE and OPE terms are derived over (ADR-0009).
vitaminc-ore = "0.10.0"
vitaminc-ore = { version = "0.10.0", features = ["prf"] }
vitaminc-prf = { version = "0.10.0", features = ["normalize"] }
vitaminc-protected = "0.10.0"
10 changes: 5 additions & 5 deletions conformance/stack-encrypt/values-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ it and the engine stores an order term, but no dynamic operator reads it.
This is a leak, not only a gap. Anyone who holds the stored rows can
compare the order terms without a key. No query uses them.

The typed Rust path has the same fault. An order index needs only
`Orderable`, but its operators need `Ordered`, and `Vec<u8>` is not
`Ordered`. The fix is to refuse an order index on `bytes` when it is
declared, at compile time on the typed path. Data that Go rc.3 stored must
stay readable. Until then, this entry keeps the behaviour visible.
The typed Rust path refuses it. An order index is bounded by vitaminc-ore's
`Orderable`, which does not cover `Vec<u8>`, so an order index on bytes
does not compile. The fix for the declaration is to refuse an order index
on `bytes` there too. Data that Go rc.3 stored must stay readable. Until
then, this entry keeps the behaviour visible.

`expected_error` cases are refused before any pending operation, with the
structured diagnostic `code`, `reason` and `field`, and no key call. They
Expand Down
6 changes: 3 additions & 3 deletions docs/target-directed-encryption.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Target-directed encryption

**Status:** design record, reconciled with the shipped API on 2026-08-28 and again on 2026-09-04 (contexts are vitaminc's `NonEmpty<T>`; a caller's context *extends* a field's own; `row = ..` became `struct = ..`, and `from` exists only there). The snippets below are the API as it ships in `stack-encrypt` (cipherstash-suite #2146, #2147); the async shape is specified by [RFC 0002](rfcs/0002-async-shape-for-target-directed-encryption.md).
**Superseded in part:** the snippets record the design as it first shipped. Since then `EncryptFrom`, `DecryptInto`, `encrypt_as`, `decrypt_as`, the plan builder and the call chain were removed. The API that ships now is `EncryptTarget` and `DecryptSource` with `encrypt_into` and `decrypt_from`, field markers for queries, and `dynamic::Planned` for a declaration that is data. See the crate docs and `packages/stack-encrypt/CHANGELOG.md`.
**Superseded in part:** the snippets record the design as it first shipped. Since then `EncryptFrom`, `DecryptInto`, `encrypt_as`, `decrypt_as`, the plan builder and the call chain were removed. The API that ships now is `EncryptTarget` and `DecryptSource` with `encrypt_into` and `decrypt_from`, field markers for queries, and `dynamic::Planned` for a declaration that is data. See the crate docs and `packages/stack-encrypt/CHANGELOG.md`. Implementation note 1 below resolved to option 1, a `Clone` bound and one copy for each term. ADR 0014 (`packages/stack-encrypt/docs/adr/0014-operations-read-the-plaintext-and-at-most-one-takes-it.md`) replaced it with option 2: every operation reads the plaintext through a reference (`EncryptRef`), and nothing is copied. Note 2's term clones are gone with it.
**Date:** 2026-08-21
**Scope:** vitaminc (primitives), stack-encrypt (the new trait + batching), eql-bindings (one class of targets)

Expand Down Expand Up @@ -303,9 +303,9 @@ An earlier iteration had two traits, `EncryptInto<T, C>` on the source and `Deri
2. Blanket `impl<T> Encrypt for &T where T: Encrypt`. vitaminc already has `impl Encrypt for &str`, so the shape exists but is not systematic.
3. Derive hands ownership to the ciphertext field and borrows to the term fields. Cheapest; puts field-ordering knowledge into the macro.

**Resolved:** (1). `S: Encrypt + Clone` on the bridge; (2) later if the copies show up in a profile.
**Resolved:** (1). `S: Encrypt + Clone` on the bridge; (2) later if the copies show up in a profile. **Superseded by ADR 0014:** (2), through vitaminc's `EncryptRef`. No plaintext is copied.

**2. Fan-out and zeroize.** **Resolved, and narrower than proposed.** The source reaches k consumers, but only the ciphertext's copy lives in `Protected` — it is held inside the pending and wiped as it seals. Term clones are ordinary values consumed during the synchronous build and dropped before any I/O; they are not wrapped. So the custody widening is bounded to the build phase for terms and to the pending's lifetime for the ciphertext. Stated in the `stack_encrypt::target` rustdoc ("Plaintext fan-out"), as this section asked.
**2. Fan-out and zeroize.** **Resolved, and narrower than proposed. Superseded by ADR 0014: no term takes a clone.** The source reaches k consumers, but only the ciphertext's copy lives in `Protected` — it is held inside the pending and wiped as it seals. Term clones are ordinary values consumed during the synchronous build and dropped before any I/O; they are not wrapped. So the custody widening is bounded to the build phase for terms and to the pending's lifetime for the ciphertext. Stated in the `stack_encrypt::target` rustdoc ("Plaintext fan-out"), as this section asked.

**3. Orphan rule.** `impl<C> EncryptFrom<i64, C> for IntegerOrdOre` in eql-bindings is legal — `Self` is local. The reverse-direction sugar (`EncryptInto::encrypt_into` on `i64`) is a blanket impl over a local trait, also fine. Worth a compile test pinning both, since the layout puts the trait, the source type and the target type in three different crates.

Expand Down
168 changes: 165 additions & 3 deletions languages/golang/encrypt/guest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading