Skip to content

stack-encrypt: a set of terms that names one index twice compiles and is refused only at run time — refuse it at compile time #1670

Open

Description

@coderdan

Background

Stack Encrypt (packages/stack-encrypt) is the Rust encryption engine that every CipherStash language SDK runs on. Encrypted<(EqualityTerm, OreTerm<u32>)> stores a ciphertext with one search term for each index in the tuple. A field may declare at most one index for each operator: two equality terms, two match terms, or ORE beside OPE are not allowed.

Problem

Since #1666, Encrypted<Terms> and a derived plaintext = T record refuse such a set with PlanError::DuplicateIndex or IndexOverlap before any key is requested. That is a run-time refusal. The plan's item Field markers and the encryption plan says a typed index set that repeats an index is refused at compile time. So Encrypted<(EqualityTerm, EqualityTerm)> still compiles, and the mistake shows only when the program runs.

Proposal

  1. Refuse a repeated or overlapping index set in the type system, for example with a trait implemented only for valid tuples, or a const assertion over each index's declared operators.
  2. Add tests/ui cases for (EqualityTerm, EqualityTerm) and (OreTerm<u32>, OpeTerm<u32>).
  3. Keep target::check_indexes for the combinators composed by hand, or document that they do not check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SDKrustPull requests that update Rust code

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions