Expand description

The order-revealing encryption scheme of docs.rs/ore-rs works on plaintexts of type u64. The encryption scheme allows ciphertexts to be compared to each other in such that two ciphertexts will reveal the ordering relationship of their plaintexts.

This is great when your plain texts are u64 but if your plaintext is not a u64 then you will need to map your plaintext domain to a corresponding u64 in such a way as to preserve ordering relationships of the original plaintext.

This module defines a type OrePlaintext<T> and From implementations on f32, f64, u8, bool, u16, u32 & u64 for OrderedInteger<u64>.

The mapping is technically reversible (no information is lost) but a reverse mapping function is not provided.

Caveat: NaN and -ve & +ve infinity & -0.0 will also be mapped and ordering is not well-defined with those values. Those values should be discarded before converting vectors of those values.

This post was used as a reference for building this implementation Converting floating point numbers to integers while preserving order


use ore_encoding_rs::OrePlaintext;

let OrePlaintext(encoded) = OrePlaintext::from(123.456f64);


An OrePlainText is a wrapper around an unsigned integer which represents a plaintext value before it is encrypted with an ORE encryption scheme.


Convenience alias for all of the traits that must be implemented by the type held by an OrePlaintext


Generate a siphash from an arbitrary length array of bytes.