poulpy/poulpy-core/src/tests/serialization.rs
poulpy-core/src/tests/serialization.rsRaw
1use poulpy_hal::tests::serialization::test_reader_writer_interface;
2
3use crate::layouts::{
4 GGLWEAutomorphismKey, GGLWECiphertext, GGLWESwitchingKey, GGLWETensorKey, GGSWCiphertext, GLWECiphertext,
5 GLWEToLWESwitchingKey, LWECiphertext, LWESwitchingKey, LWEToGLWESwitchingKey,
6 compressed::{
7 GGLWEAutomorphismKeyCompressed, GGLWECiphertextCompressed, GGLWESwitchingKeyCompressed, GGLWETensorKeyCompressed,
8 GGSWCiphertextCompressed, GLWECiphertextCompressed, GLWEToLWESwitchingKeyCompressed, LWECiphertextCompressed,
9 LWESwitchingKeyCompressed, LWEToGLWESwitchingKeyCompressed,
10 },
11};
12
13const N_GLWE: usize = 64;
14const N_LWE: usize = 32;
15const BASEK: usize = 12;
16const K: usize = 33;
17const ROWS: usize = 2;
18const RANK: usize = 2;
19const DIGITS: usize = 1;
20
21#[test]
22fn glwe_serialization() {
23 let original: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(N_GLWE, BASEK, K, RANK);
24 poulpy_hal::tests::serialization::test_reader_writer_interface(original);
25}
26
27#[test]
28fn glwe_compressed_serialization() {
29 let original: GLWECiphertextCompressed<Vec<u8>> = GLWECiphertextCompressed::alloc(N_GLWE, BASEK, K, RANK);
30 test_reader_writer_interface(original);
31}
32
33#[test]
34fn lwe_serialization() {
35 let original: LWECiphertext<Vec<u8>> = LWECiphertext::alloc(N_LWE, BASEK, K);
36 test_reader_writer_interface(original);
37}
38
39#[test]
40fn lwe_compressed_serialization() {
41 let original: LWECiphertextCompressed<Vec<u8>> = LWECiphertextCompressed::alloc(BASEK, K);
42 test_reader_writer_interface(original);
43}
44
45#[test]
46fn test_gglwe_serialization() {
47 let original: GGLWECiphertext<Vec<u8>> = GGLWECiphertext::alloc(1024, 12, 54, 3, 1, 2, 2);
48 test_reader_writer_interface(original);
49}
50
51#[test]
52fn test_gglwe_compressed_serialization() {
53 let original: GGLWECiphertextCompressed<Vec<u8>> = GGLWECiphertextCompressed::alloc(1024, 12, 54, 3, 1, 2, 2);
54 test_reader_writer_interface(original);
55}
56
57#[test]
58fn test_glwe_switching_key_serialization() {
59 let original: GGLWESwitchingKey<Vec<u8>> = GGLWESwitchingKey::alloc(1024, 12, 54, 3, 1, 2, 2);
60 test_reader_writer_interface(original);
61}
62
63#[test]
64fn test_glwe_switching_key_compressed_serialization() {
65 let original: GGLWESwitchingKeyCompressed<Vec<u8>> = GGLWESwitchingKeyCompressed::alloc(1024, 12, 54, 3, 1, 2, 2);
66 test_reader_writer_interface(original);
67}
68
69#[test]
70fn test_automorphism_key_serialization() {
71 let original: GGLWEAutomorphismKey<Vec<u8>> = GGLWEAutomorphismKey::alloc(1024, 12, 54, 3, 1, 2);
72 test_reader_writer_interface(original);
73}
74
75#[test]
76fn test_automorphism_key_compressed_serialization() {
77 let original: GGLWEAutomorphismKeyCompressed<Vec<u8>> = GGLWEAutomorphismKeyCompressed::alloc(1024, 12, 54, 3, 1, 2);
78 test_reader_writer_interface(original);
79}
80
81#[test]
82fn test_tensor_key_serialization() {
83 let original: GGLWETensorKey<Vec<u8>> = GGLWETensorKey::alloc(1024, 12, 54, 3, 1, 2);
84 test_reader_writer_interface(original);
85}
86
87#[test]
88fn test_tensor_key_compressed_serialization() {
89 let original: GGLWETensorKeyCompressed<Vec<u8>> = GGLWETensorKeyCompressed::alloc(1024, 12, 54, 3, 1, 2);
90 test_reader_writer_interface(original);
91}
92
93#[test]
94fn glwe_to_lwe_switching_key_serialization() {
95 let original: GLWEToLWESwitchingKey<Vec<u8>> = GLWEToLWESwitchingKey::alloc(N_GLWE, BASEK, K, ROWS, RANK);
96 test_reader_writer_interface(original);
97}
98
99#[test]
100fn glwe_to_lwe_switching_key_compressed_serialization() {
101 let original: GLWEToLWESwitchingKeyCompressed<Vec<u8>> = GLWEToLWESwitchingKeyCompressed::alloc(N_GLWE, BASEK, K, ROWS, RANK);
102 test_reader_writer_interface(original);
103}
104
105#[test]
106fn lwe_to_glwe_switching_key_serialization() {
107 let original: LWEToGLWESwitchingKey<Vec<u8>> = LWEToGLWESwitchingKey::alloc(N_GLWE, BASEK, K, ROWS, RANK);
108 test_reader_writer_interface(original);
109}
110
111#[test]
112fn lwe_to_glwe_switching_key_compressed_serialization() {
113 let original: LWEToGLWESwitchingKeyCompressed<Vec<u8>> = LWEToGLWESwitchingKeyCompressed::alloc(N_GLWE, BASEK, K, ROWS, RANK);
114 test_reader_writer_interface(original);
115}
116
117#[test]
118fn lwe_switching_key_serialization() {
119 let original: LWESwitchingKey<Vec<u8>> = LWESwitchingKey::alloc(N_GLWE, BASEK, K, ROWS);
120 test_reader_writer_interface(original);
121}
122
123#[test]
124fn lwe_switching_key_compressed_serialization() {
125 let original: LWESwitchingKeyCompressed<Vec<u8>> = LWESwitchingKeyCompressed::alloc(N_GLWE, BASEK, K, ROWS);
126 test_reader_writer_interface(original);
127}
128
129#[test]
130fn ggsw_serialization() {
131 let original: GGSWCiphertext<Vec<u8>> = GGSWCiphertext::alloc(N_GLWE, BASEK, K, ROWS, DIGITS, RANK);
132 test_reader_writer_interface(original);
133}
134
135#[test]
136fn ggsw_compressed_serialization() {
137 let original: GGSWCiphertextCompressed<Vec<u8>> = GGSWCiphertextCompressed::alloc(N_GLWE, BASEK, K, ROWS, DIGITS, RANK);
138 test_reader_writer_interface(original);
139}