use std::fmt; use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, source::Source, }; use crate::layouts::{GGLWESwitchingKey, Infos}; #[derive(PartialEq, Eq, Clone)] pub struct LWESwitchingKey(pub(crate) GGLWESwitchingKey); impl LWESwitchingKey> { pub fn alloc(n: usize, basek: usize, k: usize, rows: usize) -> Self { Self(GGLWESwitchingKey::alloc(n, basek, k, rows, 1, 1, 1)) } } impl fmt::Debug for LWESwitchingKey { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self) } } impl FillUniform for LWESwitchingKey { fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } impl Reset for LWESwitchingKey { fn reset(&mut self) { self.0.reset(); } } impl fmt::Display for LWESwitchingKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(LWESwitchingKey) {}", self.0) } } impl Infos for LWESwitchingKey { type Inner = MatZnx; fn inner(&self) -> &Self::Inner { self.0.inner() } fn basek(&self) -> usize { self.0.basek() } fn k(&self) -> usize { self.0.k() } } impl LWESwitchingKey { pub fn digits(&self) -> usize { self.0.digits() } pub fn rank(&self) -> usize { self.0.rank() } pub fn rank_in(&self) -> usize { self.0.rank_in() } pub fn rank_out(&self) -> usize { self.0.rank_out() } } impl ReaderFrom for LWESwitchingKey { fn read_from(&mut self, reader: &mut R) -> std::io::Result<()> { self.0.read_from(reader) } } impl WriterTo for LWESwitchingKey { fn write_to(&self, writer: &mut W) -> std::io::Result<()> { self.0.write_to(writer) } }