Skip to main content

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