ore_encoding_rs/
lib.rs

1//! The order-revealing encryption scheme of [docs.rs/ore-rs](https://docs.rs/ore-rs) works on
2//! plaintexts of type `u64`. The encryption scheme allows ciphertexts to be
3//! compared to each other in such that two ciphertexts will reveal the ordering
4//! relationship of their plaintexts.
5//!
6//! This is great when your plain texts are u64 but if your plaintext is not a
7//! `u64` then you will need to map your plaintext domain to a corresponding
8//! `u64` in such a way as to preserve ordering relationships of the original
9//! plaintext.
10//!
11//! This module defines a type `OrePlaintext<T>` and [From] implementations
12//! on [f32], [f64], [u8], [bool], [u16], [u32] & [u64] for `OrderedInteger<u64>`.
13//!
14//! The mapping is technically reversible (no information is lost) but a reverse
15//! mapping function is not provided.
16//!
17//! Caveat: NaN and -ve & +ve infinity & -0.0 will also be mapped and ordering
18//! is not well-defined with those values. Those values should be discarded
19//! before converting vectors of those values.
20//!
21//! This post was used as a reference for building this implementation
22//! [Converting floating point numbers to integers while preserving order](https://lemire.me/blog/2020/12/14/converting-floating-point-numbers-to-integers-while-preserving-order)
23//!
24//! # Example
25//!
26//! ```
27//! use ore_encoding_rs::OrePlaintext;
28//!
29//! let OrePlaintext(encoded) = OrePlaintext::from(123.456f64);
30//! ```
31
32mod encode;
33mod siphash;
34mod ranges;
35
36pub use encode::*;
37pub use ranges::*;
38pub use siphash::*;
39
40#[cfg(test)]
41#[macro_use]
42extern crate quickcheck;