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