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§
Required Methods§
Sourcefn encrypt_query(
&self,
space: &Self::Space,
plaintext: &OrderPlaintext,
) -> Result<Self::Query, Self::Error>
fn encrypt_query( &self, space: &Self::Space, plaintext: &OrderPlaintext, ) -> Result<Self::Query, Self::Error>
Sourcefn compare_query(query: &Self::Query, term: &Self::Term) -> Option<Ordering>
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".