Skip to content

stack-encrypt: one inverted-range rule for between on the typed chain and the binding #1320

Open

Description

@tobyhede

Parent

#1279

What to build

A between query whose low bound is above its high bound is refused with TermError::InvertedRange. If it were not, the user would silently get no rows. Today the rule is written twice. The typed ORE and OPE Supports impls compare the two plaintexts with >. The binding has its own comparator over the two value frames, which reads each integer's sign and 128-bit word so that one comparison covers every width.

Add a generic range function (over PartialOrd) to the crate-private op::prepare module, and have both paths call it. The binding keeps only the code that unpacks two integer bounds of the same kind from their frames. The comparison and the refusal live in the shared function. Equal bounds stay allowed on both paths.

Acceptance criteria

  • op::prepare has a range function that refuses lo > hi and accepts lo == hi.
  • The typed Between impls on ORE and OPE call it from Supports::prepare.
  • The binding's range check calls it after unpacking the bounds; the comparison and refusal code in the binding is gone.
  • Interface tests on the range function cover inverted, equal and ordered bounds.
  • The table test from the first ticket passes unchanged, including its widths up to 128 bits.
  • Single-path tests that pin only an inverted-range refusal the table now covers are removed.
  • cargo-mutants --in-diff leaves no surviving mutant in the changed code.

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    SDKenhancementNew feature or requestready-for-agentFully specified and ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions