This commit is contained in:
Pro7ech
2025-10-12 21:34:10 +02:00
parent f72363cc4b
commit 662e533eac
32 changed files with 1594 additions and 787 deletions

View File

@@ -4,7 +4,8 @@ use poulpy_hal::{
};
use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWECiphertext, GGLWEInfos, GLWECiphertext, GLWEInfos, LWEInfos, Rank, TorusPrecision,
Base2K, Degree, Dnum, Dsize, GGLWECiphertext, GGLWECiphertextToMut, GGLWEInfos, GLWECiphertext, GLWEInfos, LWEInfos, Rank,
TorusPrecision,
};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -180,6 +181,23 @@ impl GGLWESwitchingKey<Vec<u8>> {
}
}
pub trait GGLWESwitchingKeyToMut {
fn to_mut(&mut self) -> GGLWESwitchingKey<&mut [u8]>;
}
impl<D: DataMut> GGLWESwitchingKeyToMut for GGLWESwitchingKey<D>
where
GGLWECiphertext<D>: GGLWECiphertextToMut,
{
fn to_mut(&mut self) -> GGLWESwitchingKey<&mut [u8]> {
GGLWESwitchingKey {
key: self.key.to_mut(),
sk_in_n: self.sk_in_n,
sk_out_n: self.sk_out_n,
}
}
}
impl<D: DataRef> GGLWESwitchingKey<D> {
pub fn at(&self, row: usize, col: usize) -> GLWECiphertext<&[u8]> {
self.key.at(row, col)