poulpy/poulpy-schemes/src/tfhe/bdd_arithmetic/circuits/u32/xor_codegen.rs
poulpy-schemes/src/tfhe/bdd_arithmetic/circuits/u32/xor_codegen.rsRaw
1use crate::tfhe::bdd_arithmetic::{BitCircuit, BitCircuitInfo, Circuit, GetBitCircuitInfo, Node};
2pub(crate) enum AnyBitCircuit {
3 B0(BitCircuit<3, 2>),
4 B1(BitCircuit<3, 2>),
5 B2(BitCircuit<3, 2>),
6 B3(BitCircuit<3, 2>),
7 B4(BitCircuit<3, 2>),
8 B5(BitCircuit<3, 2>),
9 B6(BitCircuit<3, 2>),
10 B7(BitCircuit<3, 2>),
11 B8(BitCircuit<3, 2>),
12 B9(BitCircuit<3, 2>),
13 B10(BitCircuit<3, 2>),
14 B11(BitCircuit<3, 2>),
15 B12(BitCircuit<3, 2>),
16 B13(BitCircuit<3, 2>),
17 B14(BitCircuit<3, 2>),
18 B15(BitCircuit<3, 2>),
19 B16(BitCircuit<3, 2>),
20 B17(BitCircuit<3, 2>),
21 B18(BitCircuit<3, 2>),
22 B19(BitCircuit<3, 2>),
23 B20(BitCircuit<3, 2>),
24 B21(BitCircuit<3, 2>),
25 B22(BitCircuit<3, 2>),
26 B23(BitCircuit<3, 2>),
27 B24(BitCircuit<3, 2>),
28 B25(BitCircuit<3, 2>),
29 B26(BitCircuit<3, 2>),
30 B27(BitCircuit<3, 2>),
31 B28(BitCircuit<3, 2>),
32 B29(BitCircuit<3, 2>),
33 B30(BitCircuit<3, 2>),
34 B31(BitCircuit<3, 2>),
35}
36impl BitCircuitInfo for AnyBitCircuit {
37 fn info(&self) -> (&[Node], &[usize], usize) {
38 match self {
39 AnyBitCircuit::B0(bit_circuit) => (
40 bit_circuit.nodes.as_ref(),
41 bit_circuit.levels.as_ref(),
42 bit_circuit.max_inter_state,
43 ),
44 AnyBitCircuit::B1(bit_circuit) => (
45 bit_circuit.nodes.as_ref(),
46 bit_circuit.levels.as_ref(),
47 bit_circuit.max_inter_state,
48 ),
49 AnyBitCircuit::B2(bit_circuit) => (
50 bit_circuit.nodes.as_ref(),
51 bit_circuit.levels.as_ref(),
52 bit_circuit.max_inter_state,
53 ),
54 AnyBitCircuit::B3(bit_circuit) => (
55 bit_circuit.nodes.as_ref(),
56 bit_circuit.levels.as_ref(),
57 bit_circuit.max_inter_state,
58 ),
59 AnyBitCircuit::B4(bit_circuit) => (
60 bit_circuit.nodes.as_ref(),
61 bit_circuit.levels.as_ref(),
62 bit_circuit.max_inter_state,
63 ),
64 AnyBitCircuit::B5(bit_circuit) => (
65 bit_circuit.nodes.as_ref(),
66 bit_circuit.levels.as_ref(),
67 bit_circuit.max_inter_state,
68 ),
69 AnyBitCircuit::B6(bit_circuit) => (
70 bit_circuit.nodes.as_ref(),
71 bit_circuit.levels.as_ref(),
72 bit_circuit.max_inter_state,
73 ),
74 AnyBitCircuit::B7(bit_circuit) => (
75 bit_circuit.nodes.as_ref(),
76 bit_circuit.levels.as_ref(),
77 bit_circuit.max_inter_state,
78 ),
79 AnyBitCircuit::B8(bit_circuit) => (
80 bit_circuit.nodes.as_ref(),
81 bit_circuit.levels.as_ref(),
82 bit_circuit.max_inter_state,
83 ),
84 AnyBitCircuit::B9(bit_circuit) => (
85 bit_circuit.nodes.as_ref(),
86 bit_circuit.levels.as_ref(),
87 bit_circuit.max_inter_state,
88 ),
89 AnyBitCircuit::B10(bit_circuit) => (
90 bit_circuit.nodes.as_ref(),
91 bit_circuit.levels.as_ref(),
92 bit_circuit.max_inter_state,
93 ),
94 AnyBitCircuit::B11(bit_circuit) => (
95 bit_circuit.nodes.as_ref(),
96 bit_circuit.levels.as_ref(),
97 bit_circuit.max_inter_state,
98 ),
99 AnyBitCircuit::B12(bit_circuit) => (
100 bit_circuit.nodes.as_ref(),
101 bit_circuit.levels.as_ref(),
102 bit_circuit.max_inter_state,
103 ),
104 AnyBitCircuit::B13(bit_circuit) => (
105 bit_circuit.nodes.as_ref(),
106 bit_circuit.levels.as_ref(),
107 bit_circuit.max_inter_state,
108 ),
109 AnyBitCircuit::B14(bit_circuit) => (
110 bit_circuit.nodes.as_ref(),
111 bit_circuit.levels.as_ref(),
112 bit_circuit.max_inter_state,
113 ),
114 AnyBitCircuit::B15(bit_circuit) => (
115 bit_circuit.nodes.as_ref(),
116 bit_circuit.levels.as_ref(),
117 bit_circuit.max_inter_state,
118 ),
119 AnyBitCircuit::B16(bit_circuit) => (
120 bit_circuit.nodes.as_ref(),
121 bit_circuit.levels.as_ref(),
122 bit_circuit.max_inter_state,
123 ),
124 AnyBitCircuit::B17(bit_circuit) => (
125 bit_circuit.nodes.as_ref(),
126 bit_circuit.levels.as_ref(),
127 bit_circuit.max_inter_state,
128 ),
129 AnyBitCircuit::B18(bit_circuit) => (
130 bit_circuit.nodes.as_ref(),
131 bit_circuit.levels.as_ref(),
132 bit_circuit.max_inter_state,
133 ),
134 AnyBitCircuit::B19(bit_circuit) => (
135 bit_circuit.nodes.as_ref(),
136 bit_circuit.levels.as_ref(),
137 bit_circuit.max_inter_state,
138 ),
139 AnyBitCircuit::B20(bit_circuit) => (
140 bit_circuit.nodes.as_ref(),
141 bit_circuit.levels.as_ref(),
142 bit_circuit.max_inter_state,
143 ),
144 AnyBitCircuit::B21(bit_circuit) => (
145 bit_circuit.nodes.as_ref(),
146 bit_circuit.levels.as_ref(),
147 bit_circuit.max_inter_state,
148 ),
149 AnyBitCircuit::B22(bit_circuit) => (
150 bit_circuit.nodes.as_ref(),
151 bit_circuit.levels.as_ref(),
152 bit_circuit.max_inter_state,
153 ),
154 AnyBitCircuit::B23(bit_circuit) => (
155 bit_circuit.nodes.as_ref(),
156 bit_circuit.levels.as_ref(),
157 bit_circuit.max_inter_state,
158 ),
159 AnyBitCircuit::B24(bit_circuit) => (
160 bit_circuit.nodes.as_ref(),
161 bit_circuit.levels.as_ref(),
162 bit_circuit.max_inter_state,
163 ),
164 AnyBitCircuit::B25(bit_circuit) => (
165 bit_circuit.nodes.as_ref(),
166 bit_circuit.levels.as_ref(),
167 bit_circuit.max_inter_state,
168 ),
169 AnyBitCircuit::B26(bit_circuit) => (
170 bit_circuit.nodes.as_ref(),
171 bit_circuit.levels.as_ref(),
172 bit_circuit.max_inter_state,
173 ),
174 AnyBitCircuit::B27(bit_circuit) => (
175 bit_circuit.nodes.as_ref(),
176 bit_circuit.levels.as_ref(),
177 bit_circuit.max_inter_state,
178 ),
179 AnyBitCircuit::B28(bit_circuit) => (
180 bit_circuit.nodes.as_ref(),
181 bit_circuit.levels.as_ref(),
182 bit_circuit.max_inter_state,
183 ),
184 AnyBitCircuit::B29(bit_circuit) => (
185 bit_circuit.nodes.as_ref(),
186 bit_circuit.levels.as_ref(),
187 bit_circuit.max_inter_state,
188 ),
189 AnyBitCircuit::B30(bit_circuit) => (
190 bit_circuit.nodes.as_ref(),
191 bit_circuit.levels.as_ref(),
192 bit_circuit.max_inter_state,
193 ),
194 AnyBitCircuit::B31(bit_circuit) => (
195 bit_circuit.nodes.as_ref(),
196 bit_circuit.levels.as_ref(),
197 bit_circuit.max_inter_state,
198 ),
199 }
200 }
201}
202
203impl GetBitCircuitInfo<u32> for Circuit<AnyBitCircuit, 32usize> {
204 fn input_size(&self) -> usize {
205 2 * u32::BITS as usize
206 }
207 fn output_size(&self) -> usize {
208 u32::BITS as usize
209 }
210 fn get_circuit(&self, bit: usize) -> (&[Node], &[usize], usize) {
211 self.0[bit].info()
212 }
213}
214
215pub(crate) static OUTPUT_CIRCUITS: Circuit<AnyBitCircuit, 32usize> = Circuit([
216 AnyBitCircuit::B0(BitCircuit::new(
217 [Node::new(32, 0, 1), Node::new(32, 1, 0), Node::new(0, 0, 1)],
218 [0, 2],
219 2,
220 )),
221 AnyBitCircuit::B1(BitCircuit::new(
222 [Node::new(33, 0, 1), Node::new(33, 1, 0), Node::new(1, 0, 1)],
223 [0, 2],
224 2,
225 )),
226 AnyBitCircuit::B2(BitCircuit::new(
227 [Node::new(34, 0, 1), Node::new(34, 1, 0), Node::new(2, 0, 1)],
228 [0, 2],
229 2,
230 )),
231 AnyBitCircuit::B3(BitCircuit::new(
232 [Node::new(35, 1, 0), Node::new(35, 0, 1), Node::new(3, 1, 0)],
233 [0, 2],
234 2,
235 )),
236 AnyBitCircuit::B4(BitCircuit::new(
237 [Node::new(36, 1, 0), Node::new(36, 0, 1), Node::new(4, 1, 0)],
238 [0, 2],
239 2,
240 )),
241 AnyBitCircuit::B5(BitCircuit::new(
242 [Node::new(37, 0, 1), Node::new(37, 1, 0), Node::new(5, 0, 1)],
243 [0, 2],
244 2,
245 )),
246 AnyBitCircuit::B6(BitCircuit::new(
247 [Node::new(38, 0, 1), Node::new(38, 1, 0), Node::new(6, 0, 1)],
248 [0, 2],
249 2,
250 )),
251 AnyBitCircuit::B7(BitCircuit::new(
252 [Node::new(39, 0, 1), Node::new(39, 1, 0), Node::new(7, 0, 1)],
253 [0, 2],
254 2,
255 )),
256 AnyBitCircuit::B8(BitCircuit::new(
257 [Node::new(40, 0, 1), Node::new(40, 1, 0), Node::new(8, 0, 1)],
258 [0, 2],
259 2,
260 )),
261 AnyBitCircuit::B9(BitCircuit::new(
262 [Node::new(41, 1, 0), Node::new(41, 0, 1), Node::new(9, 1, 0)],
263 [0, 2],
264 2,
265 )),
266 AnyBitCircuit::B10(BitCircuit::new(
267 [
268 Node::new(42, 0, 1),
269 Node::new(42, 1, 0),
270 Node::new(10, 0, 1),
271 ],
272 [0, 2],
273 2,
274 )),
275 AnyBitCircuit::B11(BitCircuit::new(
276 [
277 Node::new(43, 1, 0),
278 Node::new(43, 0, 1),
279 Node::new(11, 1, 0),
280 ],
281 [0, 2],
282 2,
283 )),
284 AnyBitCircuit::B12(BitCircuit::new(
285 [
286 Node::new(44, 0, 1),
287 Node::new(44, 1, 0),
288 Node::new(12, 0, 1),
289 ],
290 [0, 2],
291 2,
292 )),
293 AnyBitCircuit::B13(BitCircuit::new(
294 [
295 Node::new(45, 1, 0),
296 Node::new(45, 0, 1),
297 Node::new(13, 1, 0),
298 ],
299 [0, 2],
300 2,
301 )),
302 AnyBitCircuit::B14(BitCircuit::new(
303 [
304 Node::new(46, 0, 1),
305 Node::new(46, 1, 0),
306 Node::new(14, 0, 1),
307 ],
308 [0, 2],
309 2,
310 )),
311 AnyBitCircuit::B15(BitCircuit::new(
312 [
313 Node::new(47, 1, 0),
314 Node::new(47, 0, 1),
315 Node::new(15, 1, 0),
316 ],
317 [0, 2],
318 2,
319 )),
320 AnyBitCircuit::B16(BitCircuit::new(
321 [
322 Node::new(48, 0, 1),
323 Node::new(48, 1, 0),
324 Node::new(16, 0, 1),
325 ],
326 [0, 2],
327 2,
328 )),
329 AnyBitCircuit::B17(BitCircuit::new(
330 [
331 Node::new(49, 1, 0),
332 Node::new(49, 0, 1),
333 Node::new(17, 1, 0),
334 ],
335 [0, 2],
336 2,
337 )),
338 AnyBitCircuit::B18(BitCircuit::new(
339 [
340 Node::new(50, 1, 0),
341 Node::new(50, 0, 1),
342 Node::new(18, 1, 0),
343 ],
344 [0, 2],
345 2,
346 )),
347 AnyBitCircuit::B19(BitCircuit::new(
348 [
349 Node::new(51, 0, 1),
350 Node::new(51, 1, 0),
351 Node::new(19, 0, 1),
352 ],
353 [0, 2],
354 2,
355 )),
356 AnyBitCircuit::B20(BitCircuit::new(
357 [
358 Node::new(52, 1, 0),
359 Node::new(52, 0, 1),
360 Node::new(20, 1, 0),
361 ],
362 [0, 2],
363 2,
364 )),
365 AnyBitCircuit::B21(BitCircuit::new(
366 [
367 Node::new(53, 1, 0),
368 Node::new(53, 0, 1),
369 Node::new(21, 1, 0),
370 ],
371 [0, 2],
372 2,
373 )),
374 AnyBitCircuit::B22(BitCircuit::new(
375 [
376 Node::new(54, 1, 0),
377 Node::new(54, 0, 1),
378 Node::new(22, 1, 0),
379 ],
380 [0, 2],
381 2,
382 )),
383 AnyBitCircuit::B23(BitCircuit::new(
384 [
385 Node::new(55, 1, 0),
386 Node::new(55, 0, 1),
387 Node::new(23, 1, 0),
388 ],
389 [0, 2],
390 2,
391 )),
392 AnyBitCircuit::B24(BitCircuit::new(
393 [
394 Node::new(56, 1, 0),
395 Node::new(56, 0, 1),
396 Node::new(24, 1, 0),
397 ],
398 [0, 2],
399 2,
400 )),
401 AnyBitCircuit::B25(BitCircuit::new(
402 [
403 Node::new(57, 1, 0),
404 Node::new(57, 0, 1),
405 Node::new(25, 1, 0),
406 ],
407 [0, 2],
408 2,
409 )),
410 AnyBitCircuit::B26(BitCircuit::new(
411 [
412 Node::new(58, 1, 0),
413 Node::new(58, 0, 1),
414 Node::new(26, 1, 0),
415 ],
416 [0, 2],
417 2,
418 )),
419 AnyBitCircuit::B27(BitCircuit::new(
420 [
421 Node::new(59, 1, 0),
422 Node::new(59, 0, 1),
423 Node::new(27, 1, 0),
424 ],
425 [0, 2],
426 2,
427 )),
428 AnyBitCircuit::B28(BitCircuit::new(
429 [
430 Node::new(60, 1, 0),
431 Node::new(60, 0, 1),
432 Node::new(28, 1, 0),
433 ],
434 [0, 2],
435 2,
436 )),
437 AnyBitCircuit::B29(BitCircuit::new(
438 [
439 Node::new(61, 0, 1),
440 Node::new(61, 1, 0),
441 Node::new(29, 0, 1),
442 ],
443 [0, 2],
444 2,
445 )),
446 AnyBitCircuit::B30(BitCircuit::new(
447 [
448 Node::new(62, 1, 0),
449 Node::new(62, 0, 1),
450 Node::new(30, 1, 0),
451 ],
452 [0, 2],
453 2,
454 )),
455 AnyBitCircuit::B31(BitCircuit::new(
456 [
457 Node::new(63, 1, 0),
458 Node::new(63, 0, 1),
459 Node::new(31, 1, 0),
460 ],
461 [0, 2],
462 2,
463 )),
464]);