tfhe/high_level_api/integers/
mod.rs1expand_pub_use_fhe_type!(
2 pub use unsigned{
3 FheUint2, FheUint4, FheUint6, FheUint8, FheUint10, FheUint12, FheUint14, FheUint16,
4 FheUint32, FheUint64, FheUint128, FheUint160, FheUint256, FheUint512, FheUint1024,
5 FheUint2048,
6 };
7);
8#[cfg(feature = "extended-types")]
9expand_pub_use_fhe_type!(
10 pub use unsigned{
11 FheUint24, FheUint40, FheUint48, FheUint56, FheUint72, FheUint80,FheUint88, FheUint96,
12 FheUint104, FheUint112, FheUint120, FheUint136, FheUint144, FheUint152, FheUint168,
13 FheUint176, FheUint184, FheUint192, FheUint200, FheUint208, FheUint216, FheUint224,
14 FheUint232, FheUint240, FheUint248,
15 };
16);
17
18expand_pub_use_fhe_type!(
19 pub use signed{
20 FheInt2, FheInt4, FheInt6, FheInt8, FheInt10, FheInt12, FheInt14, FheInt16, FheInt32,
21 FheInt64, FheInt128, FheInt160, FheInt256, FheInt512, FheInt1024, FheInt2048,
22 };
23);
24#[cfg(feature = "extended-types")]
25expand_pub_use_fhe_type!(
26 pub use signed{
27 FheInt24, FheInt40, FheInt48, FheInt56, FheInt72, FheInt80, FheInt88, FheInt96, FheInt104,
28 FheInt112, FheInt120, FheInt136, FheInt144, FheInt152, FheInt168, FheInt176, FheInt184,
29 FheInt192, FheInt200, FheInt208, FheInt216, FheInt224, FheInt232, FheInt240, FheInt248,
30 };
31);
32
33use crate::prelude::Tagged;
34use crate::ReRandomizationMetadata;
35pub(in crate::high_level_api) use signed::{
36 CompressedSignedRadixCiphertext, InnerSquashedNoiseSignedRadixCiphertextVersionOwned,
37 SignedRadixCiphertextVersionOwned,
38};
39pub(in crate::high_level_api) use unsigned::{
40 CompressedRadixCiphertext, InnerSquashedNoiseRadixCiphertextVersionOwned,
41 RadixCiphertextVersionOwned as UnsignedRadixCiphertextVersionOwned,
42};
43use crate::high_level_api::details::MaybeCloned;
45use crate::high_level_api::traits::FheId;
46use crate::shortint::MessageModulus;
47use crate::Tag;
48pub use signed::{CompressedFheInt, FheInt, FheIntId, SquashedNoiseFheInt};
49pub use unsigned::{CompressedFheUint, FheUint, FheUintId, SquashedNoiseFheUint};
50
51pub mod oprf;
52pub(super) mod signed;
53pub(super) mod unsigned;
54
55pub trait IntegerId: FheId + 'static {
59 type InnerCpu: crate::integer::IntegerRadixCiphertext;
60
61 type InnerGpu;
62
63 type InnerHpu;
64
65 fn num_bits() -> usize;
66
67 fn num_blocks(message_modulus: MessageModulus) -> usize {
68 Self::num_bits() / message_modulus.0.ilog2() as usize
69 }
70}
71
72mod private {
73 pub trait Sealed {}
74
75 impl<Id> Sealed for crate::high_level_api::FheUint<Id> where Id: super::FheUintId {}
76
77 impl<Id> Sealed for crate::high_level_api::FheInt<Id> where Id: super::FheIntId {}
78}
79
80pub trait FheIntegerType: Tagged + private::Sealed {
81 type Id: IntegerId;
82
83 fn on_cpu(&self) -> MaybeCloned<'_, <Self::Id as IntegerId>::InnerCpu>;
84
85 fn into_cpu(self) -> <Self::Id as IntegerId>::InnerCpu;
86
87 fn from_cpu(
88 inner: <Self::Id as IntegerId>::InnerCpu,
89 tag: Tag,
90 re_randomization_metadata: ReRandomizationMetadata,
91 ) -> Self;
92}