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, GGLWEInfos, GGLWESwitchingKey, GLWECiphertext, GLWEInfos, LWEInfos, Rank, TorusPrecision,
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GGLWESwitchingKey, GGLWESwitchingKeyToMut, GLWECiphertext, GLWEInfos, LWEInfos,
Rank, TorusPrecision,
};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -170,6 +171,26 @@ impl GGLWEAutomorphismKey<Vec<u8>> {
}
}
pub trait GGLWEAutomorphismKeyToMut {
fn to_mut(&mut self) -> GGLWEAutomorphismKey<&mut [u8]>;
}
impl<D: DataMut> GGLWEAutomorphismKeyToMut for GGLWEAutomorphismKey<D>
where
GGLWESwitchingKey<D>: GGLWESwitchingKeyToMut,
{
fn to_mut(&mut self) -> GGLWEAutomorphismKey<&mut [u8]> {
GGLWEAutomorphismKey {
key: self.key.to_mut(),
p: self.p,
}
}
}
pub trait GGLWEAutomorphismKeyToRef {
fn to_ref(&self) -> GGLWEAutomorphismKey<&[u8]>;
}
impl<D: DataRef> GGLWEAutomorphismKey<D> {
pub fn at(&self, row: usize, col: usize) -> GLWECiphertext<&[u8]> {
self.key.at(row, col)