Skip to content

Commit 2042174

Browse files
committed
feat(hl): add new integer types
1 parent 59bb7ba commit 2042174

File tree

12 files changed

+2137
-36
lines changed

12 files changed

+2137
-36
lines changed

tfhe/src/c_api/high_level_api/mod.rs

Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod zk;
2323
#[allow(non_camel_case_types)]
2424
pub enum FheTypes {
2525
Type_FheBool = 0,
26+
2627
Type_FheUint4 = 1,
2728
Type_FheUint8 = 2,
2829
Type_FheUint16 = 3,
@@ -39,6 +40,7 @@ pub enum FheTypes {
3940
Type_FheUint10 = 14,
4041
Type_FheUint12 = 15,
4142
Type_FheUint14 = 16,
43+
4244
Type_FheInt2 = 17,
4345
Type_FheInt4 = 18,
4446
Type_FheInt6 = 19,
@@ -52,20 +54,72 @@ pub enum FheTypes {
5254
Type_FheInt128 = 27,
5355
Type_FheInt160 = 28,
5456
Type_FheInt256 = 29,
57+
5558
Type_FheAsciiString = 30,
59+
60+
Type_FheInt512 = 31,
61+
Type_FheInt1024 = 32,
62+
Type_FheInt2048 = 33,
63+
64+
Type_FheUint24 = 34,
65+
Type_FheUint40 = 35,
66+
Type_FheUint48 = 36,
67+
Type_FheUint56 = 37,
68+
Type_FheUint72 = 38,
69+
Type_FheUint80 = 39,
70+
Type_FheUint88 = 40,
71+
Type_FheUint96 = 41,
72+
Type_FheUint104 = 42,
73+
Type_FheUint112 = 43,
74+
Type_FheUint120 = 44,
75+
Type_FheUint136 = 45,
76+
Type_FheUint144 = 46,
77+
Type_FheUint152 = 47,
78+
Type_FheUint168 = 48,
79+
Type_FheUint176 = 49,
80+
Type_FheUint184 = 50,
81+
Type_FheUint192 = 51,
82+
Type_FheUint200 = 52,
83+
Type_FheUint208 = 53,
84+
Type_FheUint216 = 54,
85+
Type_FheUint224 = 55,
86+
Type_FheUint232 = 56,
87+
Type_FheUint240 = 57,
88+
Type_FheUint248 = 58,
89+
90+
Type_FheInt24 = 59,
91+
Type_FheInt40 = 60,
92+
Type_FheInt48 = 61,
93+
Type_FheInt56 = 62,
94+
Type_FheInt72 = 63,
95+
Type_FheInt80 = 64,
96+
Type_FheInt88 = 65,
97+
Type_FheInt96 = 66,
98+
Type_FheInt104 = 67,
99+
Type_FheInt112 = 68,
100+
Type_FheInt120 = 69,
101+
Type_FheInt136 = 70,
102+
Type_FheInt144 = 71,
103+
Type_FheInt152 = 72,
104+
Type_FheInt168 = 73,
105+
Type_FheInt176 = 74,
106+
Type_FheInt184 = 75,
107+
Type_FheInt192 = 76,
108+
Type_FheInt200 = 77,
109+
Type_FheInt208 = 78,
110+
Type_FheInt216 = 79,
111+
Type_FheInt224 = 80,
112+
Type_FheInt232 = 81,
113+
Type_FheInt240 = 82,
114+
Type_FheInt248 = 83,
56115
}
57116

58117
impl From<crate::FheTypes> for FheTypes {
59118
fn from(value: crate::FheTypes) -> Self {
60119
match value {
61120
crate::FheTypes::Bool => Self::Type_FheBool,
62-
crate::FheTypes::Uint2 => Self::Type_FheUint2,
63121
crate::FheTypes::Uint4 => Self::Type_FheUint4,
64-
crate::FheTypes::Uint6 => Self::Type_FheUint6,
65122
crate::FheTypes::Uint8 => Self::Type_FheUint8,
66-
crate::FheTypes::Uint10 => Self::Type_FheUint10,
67-
crate::FheTypes::Uint12 => Self::Type_FheUint12,
68-
crate::FheTypes::Uint14 => Self::Type_FheUint14,
69123
crate::FheTypes::Uint16 => Self::Type_FheUint16,
70124
crate::FheTypes::Uint32 => Self::Type_FheUint32,
71125
crate::FheTypes::Uint64 => Self::Type_FheUint64,
@@ -75,6 +129,11 @@ impl From<crate::FheTypes> for FheTypes {
75129
crate::FheTypes::Uint512 => Self::Type_FheUint512,
76130
crate::FheTypes::Uint1024 => Self::Type_FheUint1024,
77131
crate::FheTypes::Uint2048 => Self::Type_FheUint2048,
132+
crate::FheTypes::Uint2 => Self::Type_FheUint2,
133+
crate::FheTypes::Uint6 => Self::Type_FheUint6,
134+
crate::FheTypes::Uint10 => Self::Type_FheUint10,
135+
crate::FheTypes::Uint12 => Self::Type_FheUint12,
136+
crate::FheTypes::Uint14 => Self::Type_FheUint14,
78137
crate::FheTypes::Int2 => Self::Type_FheInt2,
79138
crate::FheTypes::Int4 => Self::Type_FheInt4,
80139
crate::FheTypes::Int6 => Self::Type_FheInt6,
@@ -89,6 +148,59 @@ impl From<crate::FheTypes> for FheTypes {
89148
crate::FheTypes::Int160 => Self::Type_FheInt160,
90149
crate::FheTypes::Int256 => Self::Type_FheInt256,
91150
crate::FheTypes::AsciiString => Self::Type_FheAsciiString,
151+
crate::FheTypes::Int512 => Self::Type_FheInt512,
152+
crate::FheTypes::Int1024 => Self::Type_FheInt1024,
153+
crate::FheTypes::Int2048 => Self::Type_FheInt2048,
154+
crate::FheTypes::Uint24 => Self::Type_FheUint24,
155+
crate::FheTypes::Uint40 => Self::Type_FheUint40,
156+
crate::FheTypes::Uint48 => Self::Type_FheUint48,
157+
crate::FheTypes::Uint56 => Self::Type_FheUint56,
158+
crate::FheTypes::Uint72 => Self::Type_FheUint72,
159+
crate::FheTypes::Uint80 => Self::Type_FheUint80,
160+
crate::FheTypes::Uint88 => Self::Type_FheUint88,
161+
crate::FheTypes::Uint96 => Self::Type_FheUint96,
162+
crate::FheTypes::Uint104 => Self::Type_FheUint104,
163+
crate::FheTypes::Uint112 => Self::Type_FheUint112,
164+
crate::FheTypes::Uint120 => Self::Type_FheUint120,
165+
crate::FheTypes::Uint136 => Self::Type_FheUint136,
166+
crate::FheTypes::Uint144 => Self::Type_FheUint144,
167+
crate::FheTypes::Uint152 => Self::Type_FheUint152,
168+
crate::FheTypes::Uint168 => Self::Type_FheUint168,
169+
crate::FheTypes::Uint176 => Self::Type_FheUint176,
170+
crate::FheTypes::Uint184 => Self::Type_FheUint184,
171+
crate::FheTypes::Uint192 => Self::Type_FheUint192,
172+
crate::FheTypes::Uint200 => Self::Type_FheUint200,
173+
crate::FheTypes::Uint208 => Self::Type_FheUint208,
174+
crate::FheTypes::Uint216 => Self::Type_FheUint216,
175+
crate::FheTypes::Uint224 => Self::Type_FheUint224,
176+
crate::FheTypes::Uint232 => Self::Type_FheUint232,
177+
crate::FheTypes::Uint240 => Self::Type_FheUint240,
178+
crate::FheTypes::Uint248 => Self::Type_FheUint248,
179+
crate::FheTypes::Int24 => Self::Type_FheInt24,
180+
crate::FheTypes::Int40 => Self::Type_FheInt40,
181+
crate::FheTypes::Int48 => Self::Type_FheInt48,
182+
crate::FheTypes::Int56 => Self::Type_FheInt56,
183+
crate::FheTypes::Int72 => Self::Type_FheInt72,
184+
crate::FheTypes::Int80 => Self::Type_FheInt80,
185+
crate::FheTypes::Int88 => Self::Type_FheInt88,
186+
crate::FheTypes::Int96 => Self::Type_FheInt96,
187+
crate::FheTypes::Int104 => Self::Type_FheInt104,
188+
crate::FheTypes::Int112 => Self::Type_FheInt112,
189+
crate::FheTypes::Int120 => Self::Type_FheInt120,
190+
crate::FheTypes::Int136 => Self::Type_FheInt136,
191+
crate::FheTypes::Int144 => Self::Type_FheInt144,
192+
crate::FheTypes::Int152 => Self::Type_FheInt152,
193+
crate::FheTypes::Int168 => Self::Type_FheInt168,
194+
crate::FheTypes::Int176 => Self::Type_FheInt176,
195+
crate::FheTypes::Int184 => Self::Type_FheInt184,
196+
crate::FheTypes::Int192 => Self::Type_FheInt192,
197+
crate::FheTypes::Int200 => Self::Type_FheInt200,
198+
crate::FheTypes::Int208 => Self::Type_FheInt208,
199+
crate::FheTypes::Int216 => Self::Type_FheInt216,
200+
crate::FheTypes::Int224 => Self::Type_FheInt224,
201+
crate::FheTypes::Int232 => Self::Type_FheInt232,
202+
crate::FheTypes::Int240 => Self::Type_FheInt240,
203+
crate::FheTypes::Int248 => Self::Type_FheInt248,
92204
}
93205
}
94206
}

tfhe/src/high_level_api/compact_list.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,35 @@ impl crate::FheTypes {
4646
12 => Self::Uint12,
4747
14 => Self::Uint14,
4848
16 => Self::Uint16,
49+
24 => Self::Uint24,
4950
32 => Self::Uint32,
51+
40 => Self::Uint40,
52+
48 => Self::Uint48,
53+
56 => Self::Uint56,
5054
64 => Self::Uint64,
55+
72 => Self::Uint72,
56+
80 => Self::Uint80,
57+
88 => Self::Uint88,
58+
96 => Self::Uint96,
59+
104 => Self::Uint104,
60+
112 => Self::Uint112,
61+
120 => Self::Uint120,
5162
128 => Self::Uint128,
63+
136 => Self::Uint136,
64+
144 => Self::Uint144,
65+
152 => Self::Uint152,
5266
160 => Self::Uint160,
67+
168 => Self::Uint168,
68+
176 => Self::Uint176,
69+
184 => Self::Uint184,
70+
192 => Self::Uint192,
71+
200 => Self::Uint200,
72+
208 => Self::Uint208,
73+
216 => Self::Uint216,
74+
224 => Self::Uint224,
75+
232 => Self::Uint232,
76+
240 => Self::Uint240,
77+
248 => Self::Uint248,
5378
256 => Self::Uint256,
5479
512 => Self::Uint512,
5580
1024 => Self::Uint1024,
@@ -69,11 +94,39 @@ impl crate::FheTypes {
6994
12 => Self::Int12,
7095
14 => Self::Int14,
7196
16 => Self::Int16,
97+
24 => Self::Int24,
7298
32 => Self::Int32,
99+
40 => Self::Int40,
100+
48 => Self::Int48,
101+
56 => Self::Int56,
73102
64 => Self::Int64,
103+
72 => Self::Int72,
104+
80 => Self::Int80,
105+
88 => Self::Int88,
106+
96 => Self::Int96,
107+
104 => Self::Int104,
108+
112 => Self::Int112,
109+
120 => Self::Int120,
74110
128 => Self::Int128,
111+
136 => Self::Int136,
112+
144 => Self::Int144,
113+
152 => Self::Int152,
75114
160 => Self::Int160,
115+
168 => Self::Int168,
116+
176 => Self::Int176,
117+
184 => Self::Int184,
118+
192 => Self::Int192,
119+
200 => Self::Int200,
120+
208 => Self::Int208,
121+
216 => Self::Int216,
122+
224 => Self::Int224,
123+
232 => Self::Int232,
124+
240 => Self::Int240,
125+
248 => Self::Int248,
76126
256 => Self::Int256,
127+
512 => Self::Int512,
128+
1024 => Self::Int1024,
129+
2048 => Self::Int2048,
77130
_ => return None,
78131
}
79132
}

tfhe/src/high_level_api/integers/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
expand_pub_use_fhe_type!(
22
pub use unsigned{
33
FheUint2, FheUint4, FheUint6, FheUint8, FheUint10, FheUint12, FheUint14, FheUint16,
4-
FheUint32, FheUint64, FheUint128, FheUint160, FheUint256, FheUint512, FheUint1024, FheUint2048,
4+
FheUint24, FheUint32, FheUint40, FheUint48, FheUint56, FheUint64, FheUint72, FheUint80,
5+
FheUint88, FheUint96, FheUint104, FheUint112, FheUint120, FheUint128, FheUint136,
6+
FheUint144, FheUint152, FheUint160, FheUint168, FheUint176, FheUint184, FheUint192,
7+
FheUint200, FheUint208, FheUint216, FheUint224, FheUint232, FheUint240, FheUint248,
8+
FheUint256, FheUint512, FheUint1024, FheUint2048,
59
};
610
);
711

812
expand_pub_use_fhe_type!(
913
pub use signed{
10-
FheInt2, FheInt4, FheInt6, FheInt8, FheInt10, FheInt12, FheInt14, FheInt16,
11-
FheInt32, FheInt64, FheInt128, FheInt160, FheInt256
14+
FheInt2, FheInt4, FheInt6, FheInt8, FheInt10, FheInt12, FheInt14, FheInt16, FheInt24,
15+
FheInt32, FheInt40, FheInt48, FheInt56, FheInt64, FheInt72, FheInt80, FheInt88, FheInt96,
16+
FheInt104, FheInt112, FheInt120, FheInt128, FheInt136, FheInt144, FheInt152, FheInt160,
17+
FheInt168, FheInt176, FheInt184, FheInt192, FheInt200, FheInt208, FheInt216, FheInt224,
18+
FheInt232, FheInt240, FheInt248, FheInt256, FheInt512, FheInt1024, FheInt2048,
1219
};
1320
);
1421

tfhe/src/high_level_api/integers/signed/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ pub(in crate::high_level_api) use inner::{RadixCiphertext, RadixCiphertextVersio
1717

1818
expand_pub_use_fhe_type!(
1919
pub use static_{
20-
FheInt2, FheInt4, FheInt6, FheInt8, FheInt10, FheInt12, FheInt14, FheInt16,
21-
FheInt32, FheInt64, FheInt128, FheInt160, FheInt256
20+
FheInt2, FheInt4, FheInt6, FheInt8, FheInt10, FheInt12, FheInt14, FheInt16, FheInt24,
21+
FheInt32, FheInt40, FheInt48, FheInt56, FheInt64, FheInt72, FheInt80, FheInt88, FheInt96,
22+
FheInt104, FheInt112, FheInt120, FheInt128, FheInt136, FheInt144, FheInt152, FheInt160,
23+
FheInt168, FheInt176, FheInt184, FheInt192, FheInt200, FheInt208, FheInt216, FheInt224,
24+
FheInt232, FheInt240, FheInt248, FheInt256, FheInt512, FheInt1024, FheInt2048
2225
};
2326
);

0 commit comments

Comments
 (0)