Debian Codegraph @

third_party/rust/clubcard/src/lib.rs

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 //! **UNSTABLE / EXPERIMENTAL**
6 //!
7 //! Clubcard is a compact data-structure that solves the exact membership query problem.
8 //!
9 //! Given some universe of objects U, a subset R of U, and two hash functions defined on U (as
10 //! described below), Clubcard outputs a compact encoding of the function `f : U -> {0, 1}` defined
11 //! by `f(x) = 0 if and only if x ∈ R`.
12 //!
13 //! Clubcard is based on the Ribbon filters from
14 //! - <https://arxiv.org/pdf/2103.02515>, and
15 //! - <https://arxiv.org/pdf/2109.01892>
16 //!
17 //! And some ideas from Mike Hamburg's RWC 2022 talk
18 //! - <https://rwc.iacr.org/2022/program.php#abstract-talk-39>
19 //! - <https://youtu.be/Htms5rNy7B8?list=PLeeS-3Ml-rpovBDh6do693We_CP3KTnHU&t=2357>
20 //!
21 //! The construction will be described in detail in a forthcoming paper.
22 //!
23 //! At a high level, a clubcard is a pair of matrices (X, Y) defined over GF(2). The hash
24 //! functions h and g map elements of U to vectors in the domain of X and Y respectively.
25 //!
26 //! The matrix X is a solution to `H * X = 0` where the rows of H are obtained by hashing the
27 //! elements of R with h. The number of columns in X is floor(lg(|U\R| / |R|)).
28 //!
29 //! The matrix Y is a solution to `G * Y = C` where the rows of G are obtained by hashing, with g,
30 //! the elements u ∈ U for which h(u) * X = 0. The matrix Y has one column. The rows of C encode
31 //! membership in R.
32 //!
33 //! Given (X, Y) and an element u ∈ U, we have that u ∈ R iff h(u) * X == 0 and g(u) * Y = 0.
34 //!
35 //! Clubcard was developed to replace the use of Bloom cascades in CRLite. In a preliminary
36 //! experiment using a real-world collection of 12.2M revoked certs and 789.2M non-revoked certs,
37 //! the currently-deployed Bloom cascade implementation of CRLite produces a 19.8MB filter in 293
38 //! seconds (on a Ryzen 3975WX with 64GB of RAM). This Clubcard implementation produces an 8.5MB
39 //! filter in 200 seconds.
40 //!
41 //#![warn(missing_docs)]
42
43 #[cfg(feature = "builder")]
44 pub mod builder;
45
46 mod clubcard;
47 pub use clubcard::{ApproximateSizeOf, Clubcard, ClubcardIndex, ClubcardIndexEntry, Membership};
48
49 mod equation;
50 pub use equation::Equation;
51
52 mod query;
53 pub use query::{AsQuery, Filterable, Queryable};