Skip to main content

OrderQuery

Trait OrderQuery 

Source
pub trait OrderQuery: OrderScheme {
    type Query: AsRef<[u8]>;

    // Required methods
    fn encrypt_query(
        &self,
        space: &Self::Space,
        plaintext: &OrderPlaintext,
    ) -> Result<Self::Query, Self::Error>;
    fn compare_query(query: &Self::Query, term: &Self::Term) -> Option<Ordering>;
}
Expand description

An order scheme that makes queries: what a caller makes from the value it is searching for, to compare against the space’s stored terms.

Implemented beside OrderScheme by a scheme that has a query side, and trivially, with Query = Term, by one whose terms are their own queries. A caller does not call it: it makes queries through OrderSpace::encrypt_query and compares them through OrderSpace::compare_query, so a query is bound to the same salt as the terms it is compared with.

A query exists for the comparison at hand, and should not be persisted or logged. Held beside the stored terms, it orders every one of them against the searched value, for whoever holds both. And block ORE’s queries are deterministic, one value in one space giving one query, so == on two of its queries is equality of the values searched for, and a log of queries is a log of what was searched.

That is the whole of what a query is guarded against: being kept. It is not wiped from memory when it drops, and Query has no bound that would make it wipe itself, unlike a scheme’s Space. A query is made to be sent to the database, which sees it in order to compare with it, and the process that made it also holds the plaintext it came from and the scheme’s key. Bytes of a query left in that process’s memory give away less than what sits beside them.

Required Associated Types§

Source

type Query: AsRef<[u8]>

What one query encrypts to. For a scheme whose terms are their own queries, Term. It need not wipe itself; see above for why.

Required Methods§

Source

fn encrypt_query( &self, space: &Self::Space, plaintext: &OrderPlaintext, ) -> Result<Self::Query, Self::Error>

Encrypt a sealed plaintext of space as a query, with what open made under the space’s salt.

The plaintext is of a target the scheme Supports: the space checks before calling. So the only failure is the scheme’s own.

§Errors

The scheme’s own failure.

Source

fn compare_query(query: &Self::Query, term: &Self::Term) -> Option<Ordering>

The order of the value query encrypts relative to the value term encrypts: Less when the queried value sorts before the stored one. Needs no key, as compare does not.

None says the two cannot be compared: one is not this scheme’s, or the two were not made to compare. The same contract as compare: across spaces the noise is in the direction and never in equality.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§