tfhe/
lib.rs

1//! Welcome to the TFHE-rs API documentation!
2//!
3//! TFHE-rs is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE.
4
5// Enable all warnings in doctests
6// https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#showing-warnings-in-doctests
7#![doc(test(attr(warn(unused))))]
8#![doc(test(attr(allow(unused_variables))))]
9#![doc(test(attr(allow(unused_imports))))]
10// Enable all warnings first as it may break the "allow" priority/activation as some lints gets
11// moved around in clippy categories
12
13// Enable pedantic lints
14#![warn(clippy::pedantic)]
15// Nursery lints
16#![warn(clippy::nursery)]
17#![warn(rustdoc::broken_intra_doc_links)]
18// The following lints have been temporarily allowed
19// They are expected to be fixed progressively
20#![allow(clippy::unreadable_literal)] // 830
21#![allow(clippy::doc_markdown)] // 688
22#![allow(clippy::missing_panics_doc)] // 667
23#![allow(clippy::cast_possible_truncation)] // 540
24#![allow(clippy::similar_names)] // 514
25#![allow(clippy::must_use_candidate)] // 356
26#![allow(clippy::wildcard_imports)] // 350
27#![allow(clippy::module_name_repetitions)] // 328
28#![allow(clippy::cast_lossless)] // 280
29#![allow(clippy::missing_const_for_fn)] // 243
30#![allow(clippy::missing_errors_doc)] // 118
31#![allow(clippy::cast_precision_loss)] // 102
32#![allow(clippy::items_after_statements)] // 99
33#![allow(clippy::cast_sign_loss)] // 97
34#![allow(clippy::inline_always)] // 51
35#![allow(clippy::many_single_char_names)] // 44
36#![allow(clippy::too_many_lines)] // 34
37#![allow(clippy::match_same_arms)] // 19
38#![allow(clippy::range_plus_one)] // 16
39#![allow(clippy::return_self_not_must_use)] // 11
40#![allow(clippy::ignored_unit_patterns)] // 9
41#![allow(clippy::large_types_passed_by_value)] // 8
42#![allow(clippy::float_cmp)] // 7
43#![allow(clippy::bool_to_int_with_if)] // 6
44#![allow(clippy::unsafe_derive_deserialize)] // 1
45#![allow(clippy::cast_possible_wrap)] // 1
46#![allow(clippy::too_long_first_doc_paragraph)]
47#![allow(clippy::redundant_closure_for_method_calls)]
48// These pedantic lints are deemed to bring too little value therefore they are allowed (which are
49// their natural state anyways, being pedantic lints)
50
51// Would require a ; for the last statement of a function even if the function returns (), compiler
52// indicates it is for formatting consistency, cargo fmt works well with it allowed anyways.
53#![allow(clippy::semicolon_if_nothing_returned)]
54// Warns when iter or iter_mut are called explicitly, but it reads more nicely e.g. when there are
55// parallel and sequential iterators that are mixed
56#![allow(clippy::explicit_iter_loop)]
57// Warns for field names that have a common prefix/suffix or that include the name of the type.
58// Renaming fields would be a data breaking change, plus we often want the extra verbosity
59#![allow(clippy::struct_field_names)]
60// End allowed pedantic lints
61
62// The following lints have been temporarily allowed
63// They are expected to be fixed progressively
64#![allow(clippy::missing_const_for_fn)] // 243
65#![allow(clippy::redundant_pub_crate)] // 116
66#![allow(clippy::suboptimal_flops)] // 43
67#![allow(clippy::significant_drop_tightening)] // 10
68#![allow(clippy::cognitive_complexity)] // 6
69#![allow(clippy::iter_with_drain)] // 2
70#![allow(clippy::large_stack_frames)] // 1
71#![cfg_attr(feature = "__wasm_api", allow(dead_code))]
72#![cfg_attr(
73    all(
74        any(target_arch = "x86", target_arch = "x86_64"),
75        feature = "nightly-avx512"
76    ),
77    feature(avx512_target_feature, stdarch_x86_avx512)
78)]
79#![cfg_attr(all(doc, not(doctest)), feature(doc_auto_cfg))]
80#![cfg_attr(all(doc, not(doctest)), feature(doc_cfg))]
81// Weird clippy lint triggering without any code location
82#![cfg_attr(test, allow(clippy::large_stack_arrays))]
83
84#[cfg(feature = "__c_api")]
85pub mod c_api;
86
87#[cfg(feature = "boolean")]
88/// Welcome to the TFHE-rs [`boolean`](`crate::boolean`) module documentation!
89///
90/// # Special module attributes
91/// cbindgen:ignore
92pub mod boolean;
93
94/// Welcome to the TFHE-rs [`core_crypto`](`crate::core_crypto`) module documentation!
95///
96/// # Special module attributes
97/// cbindgen:ignore
98pub mod core_crypto;
99
100#[cfg(feature = "integer")]
101/// Welcome to the TFHE-rs [`integer`](`crate::integer`) module documentation!
102///
103/// # Special module attributes
104/// cbindgen:ignore
105pub mod integer;
106
107#[cfg(feature = "shortint")]
108/// Welcome to the TFHE-rs [`shortint`](`crate::shortint`) module documentation!
109///
110/// # Special module attributes
111/// cbindgen:ignore
112pub mod shortint;
113
114#[cfg(feature = "pbs-stats")]
115pub use shortint::server_key::pbs_stats::*;
116
117#[cfg(feature = "__wasm_api")]
118/// cbindgen:ignore
119mod js_on_wasm_api;
120
121#[cfg(all(
122    doctest,
123    feature = "shortint",
124    feature = "boolean",
125    feature = "integer",
126    feature = "zk-pok",
127    feature = "strings"
128))]
129mod test_user_docs;
130
131#[cfg(feature = "strings")]
132pub mod strings;
133
134#[cfg(feature = "integer")]
135/// cbindgen:ignore
136pub(crate) mod high_level_api;
137
138#[cfg(feature = "integer")]
139pub use high_level_api::*;
140
141#[cfg(any(test, doctest, feature = "internal-keycache"))]
142/// cbindgen:ignore
143pub mod keycache;
144
145pub mod safe_serialization;
146
147pub mod conformance;
148
149pub mod named;
150
151pub mod error;
152#[cfg(feature = "zk-pok")]
153pub mod zk;
154
155#[cfg(any(feature = "integer", feature = "shortint"))]
156pub(crate) use error::error;
157pub use error::{Error, ErrorKind};
158pub type Result<T> = std::result::Result<T, Error>;
159
160pub use tfhe_versionable::{Unversionize, Versionize};
161
162/// Export tfhe-hpu-backend for external use
163#[cfg(feature = "hpu")]
164pub use tfhe_hpu_backend;