You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ccd4431
Browse filesBrowse the repository at this point in the historyBrowse files
feat(stack-encrypt)!: let an inverted Between range through, as SQL does
A `Between` whose low bound is above its high bound was refused with
`TermError::InvertedRange` before either term was derived. SQL's own
`BETWEEN` refuses nothing: `x BETWEEN 20 AND 10` is a valid query that
matches no row, and an encrypted range now behaves the same way. The
empty result leaks nothing and corrupts nothing, so a refusal bought
little.
It also cost more than it bought. Judging a range correctly for text and
floats means reproducing, before encryption, the order the index
compares in: text by its fold, floats by their canonical encoding. The
check did that by encrypting both bounds under a fixed public OPE key,
which tied a query-time refusal to one scheme's ciphertext. That order
belongs to the ORE crates, not to this one.
So `TermError::InvertedRange` (code `stack_encrypt::inverted_range`)
goes, with the typed path's `Ordered::inverted`, the data path's
`bound_order` and `integer_order`, and the comparison scheme behind
them. The variant is under [Unreleased] and never shipped.
The data path still refuses order text with no fold (a code point
Unicode 16 does not assign) before a term or a keyset, for one value and
now for each bound of a pair. It asks `vitaminc_ore::text` directly,
which is the encoding `vitaminc_ore::order` uses for the `Text` target,
so it refuses exactly what derivation would.
Claude-Session: https://claude.ai/code/session_01BZhkvKLpNtKuzj3HCfMXoL
Copy file name to clipboardExpand all lines: packages/stack-encrypt/docs/adr/0009-operators-select-the-index-and-a-query-term-is-not-the-stored-term.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -572,9 +572,11 @@ the ranked loop is worth packaging; it is deferred, not refused.
572
572
573
573
`cipher.query(op::Between, &(lo, hi)).on(&plan)` produces one term,
574
574
`sem::RangeQuery`, carrying the index's term for each bound (the ORE left
575
-
ciphertexts, once block ORE lands), inclusive at both ends, and the client
576
-
refuses `lo > hi` (`TermError::InvertedRange`) before either term is
577
-
derived; `(v, v)` is one value. One call derives both bounds, under one
575
+
ciphertexts, once block ORE lands), inclusive at both ends; `(v, v)` is one
576
+
value. The client does not refuse `lo > hi`: as SQL's `BETWEEN`, such a
577
+
range matches nothing. Judging it would mean reproducing, before
578
+
encryption, the order the index compares in (text by its fold, floats by
579
+
their canonical encoding), which belongs to the ORE crates. One call derives both bounds, under one
578
580
context, so a caller cannot pair a bound from one column with a bound from
579
581
another. The ordering operators are answered over the integer types and
580
582
text (`op::Ordered`), by the ORE index by default and by OPE through
0 commit comments