Removed traits on structs not dependent on Module API

This commit is contained in:
Pro7ech
2025-10-20 10:32:02 +02:00
parent 60fbd3e625
commit 53bc78f421
50 changed files with 858 additions and 2010 deletions

View File

@@ -1,5 +1,4 @@
use poulpy_backend::FFT64Ref;
use poulpy_hal::{api::ModuleNew, layouts::Module, test_suite::serialization::test_reader_writer_interface};
use poulpy_hal::test_suite::serialization::test_reader_writer_interface;
use crate::layouts::{
AutomorphismKey, Base2K, Degree, Dnum, Dsize, GGLWE, GGSW, GLWE, GLWESwitchingKey, GLWEToLWESwitchingKey, LWE,
@@ -21,143 +20,123 @@ const DSIZE: Dsize = Dsize(1);
#[test]
fn glwe_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWE<Vec<u8>> = GLWE::alloc(&module, BASE2K, K, RANK);
let original: GLWE<Vec<u8>> = GLWE::alloc(N_GLWE, BASE2K, K, RANK);
poulpy_hal::test_suite::serialization::test_reader_writer_interface(original);
}
#[test]
fn glwe_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWECompressed<Vec<u8>> = GLWECompressed::alloc(&module, BASE2K, K, RANK);
let original: GLWECompressed<Vec<u8>> = GLWECompressed::alloc(N_GLWE, BASE2K, K, RANK);
test_reader_writer_interface(original);
}
#[test]
fn lwe_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWE<Vec<u8>> = LWE::alloc(&module, N_LWE, BASE2K, K);
let original: LWE<Vec<u8>> = LWE::alloc(N_LWE, BASE2K, K);
test_reader_writer_interface(original);
}
#[test]
fn lwe_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWECompressed<Vec<u8>> = LWECompressed::alloc(&module, BASE2K, K);
let original: LWECompressed<Vec<u8>> = LWECompressed::alloc(BASE2K, K);
test_reader_writer_interface(original);
}
#[test]
fn test_gglwe_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GGLWE<Vec<u8>> = GGLWE::alloc(&module, BASE2K, K, RANK, RANK, DNUM, DSIZE);
let original: GGLWE<Vec<u8>> = GGLWE::alloc(N_GLWE, BASE2K, K, RANK, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_gglwe_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GGLWECompressed<Vec<u8>> = GGLWECompressed::alloc(&module, BASE2K, K, RANK, RANK, DNUM, DSIZE);
let original: GGLWECompressed<Vec<u8>> = GGLWECompressed::alloc(N_GLWE, BASE2K, K, RANK, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_glwe_switching_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWESwitchingKey<Vec<u8>> = GLWESwitchingKey::alloc(&module, BASE2K, K, RANK, RANK, DNUM, DSIZE);
let original: GLWESwitchingKey<Vec<u8>> = GLWESwitchingKey::alloc(N_GLWE, BASE2K, K, RANK, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_glwe_switching_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWESwitchingKeyCompressed<Vec<u8>> =
GLWESwitchingKeyCompressed::alloc(&module, BASE2K, K, RANK, RANK, DNUM, DSIZE);
GLWESwitchingKeyCompressed::alloc(N_GLWE, BASE2K, K, RANK, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_automorphism_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: AutomorphismKey<Vec<u8>> = AutomorphismKey::alloc_with(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: AutomorphismKey<Vec<u8>> = AutomorphismKey::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_automorphism_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: AutomorphismKeyCompressed<Vec<u8>> = AutomorphismKeyCompressed::alloc(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: AutomorphismKeyCompressed<Vec<u8>> = AutomorphismKeyCompressed::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_tensor_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: TensorKey<Vec<u8>> = TensorKey::alloc(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: TensorKey<Vec<u8>> = TensorKey::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn test_tensor_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: TensorKeyCompressed<Vec<u8>> = TensorKeyCompressed::alloc(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: TensorKeyCompressed<Vec<u8>> = TensorKeyCompressed::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn glwe_to_lwe_switching_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWEToLWESwitchingKey<Vec<u8>> = GLWEToLWESwitchingKey::alloc(&module, BASE2K, K, RANK, DNUM);
let original: GLWEToLWESwitchingKey<Vec<u8>> = GLWEToLWESwitchingKey::alloc(N_GLWE, BASE2K, K, RANK, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn glwe_to_lwe_switching_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GLWEToLWESwitchingKeyCompressed<Vec<u8>> =
GLWEToLWESwitchingKeyCompressed::alloc(&module, BASE2K, K, RANK, DNUM);
GLWEToLWESwitchingKeyCompressed::alloc(N_GLWE, BASE2K, K, RANK, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn lwe_to_glwe_switching_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWEToGLWESwitchingKey<Vec<u8>> = LWEToGLWESwitchingKey::alloc(&module, BASE2K, K, RANK, DNUM);
let original: LWEToGLWESwitchingKey<Vec<u8>> = LWEToGLWESwitchingKey::alloc(N_GLWE, BASE2K, K, RANK, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn lwe_to_glwe_switching_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWEToGLWESwitchingKeyCompressed<Vec<u8>> =
LWEToGLWESwitchingKeyCompressed::alloc_with(&module, BASE2K, K, RANK, DNUM);
LWEToGLWESwitchingKeyCompressed::alloc(N_GLWE, BASE2K, K, RANK, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn lwe_switching_key_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWESwitchingKey<Vec<u8>> = LWESwitchingKey::alloc(&module, BASE2K, K, DNUM);
let original: LWESwitchingKey<Vec<u8>> = LWESwitchingKey::alloc(N_GLWE, BASE2K, K, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn lwe_switching_key_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: LWESwitchingKeyCompressed<Vec<u8>> = LWESwitchingKeyCompressed::alloc(&module, BASE2K, K, DNUM);
let original: LWESwitchingKeyCompressed<Vec<u8>> = LWESwitchingKeyCompressed::alloc(N_GLWE, BASE2K, K, DNUM);
test_reader_writer_interface(original);
}
#[test]
fn ggsw_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GGSW<Vec<u8>> = GGSW::alloc(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: GGSW<Vec<u8>> = GGSW::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}
#[test]
fn ggsw_compressed_serialization() {
let module: Module<FFT64Ref> = Module::<FFT64Ref>::new(N_GLWE.as_u32() as u64);
let original: GGSWCompressed<Vec<u8>> = GGSWCompressed::alloc(&module, BASE2K, K, RANK, DNUM, DSIZE);
let original: GGSWCompressed<Vec<u8>> = GGSWCompressed::alloc(N_GLWE, BASE2K, K, RANK, DNUM, DSIZE);
test_reader_writer_interface(original);
}